Permalink
Browse files

[enhance] launch_helper, qml2js: node modules dependencies check are …

…made in opa-js-runtime, more reliable
  • Loading branch information...
1 parent 88c5f85 commit 8dce9fffa4e0e70475e12e7ef6f0ee670e304471 @Aqua-Ye Aqua-Ye committed Dec 10, 2012
Showing with 25 additions and 18 deletions.
  1. +22 −0 compiler/qml2js/clientLibLib.js
  2. +3 −3 compiler/qml2js/qml2js.ml
  3. +0 −15 tools/dependencies/launch_helper.js
View
22 compiler/qml2js/clientLibLib.js
@@ -80,3 +80,25 @@ function js_assert(b, s){
var js_debug = function(s)
{
}
+
+/**
+ * FIXME: should be put elsewhere
+ */
+
+function check_opa_deps(dependencies){
+ var deps = dependencies.filter(function(dependency, index, array) {
+ // console.log('Checking', dependency, '...');
+ try {
+ require(dependency);
+ return false;
+ } catch(e) {
+ if (process.version < "v0.8.0") return true;
+ return (e.code === 'MODULE_NOT_FOUND');
+ }
+ });
+
+ if (deps.length > 0) {
+ console.error(deps.length+' modules are missing.', 'Please run: sudo npm install -g', deps.join(' '));
+ process.exit(1);
+ }
+}
View
6 compiler/qml2js/qml2js.ml
@@ -154,15 +154,15 @@ struct
export NODE_PATH=\"%a\"
%s
*/
-
-var dependencies = [%a];
%s
+require('opa-js-runtime-cps');
+check_opa_deps([%a]);
"
(StringSet.pp ":" Format.pp_print_string) node_path
LaunchHelper.script
- (Format.pp_list ", " (fun fmt s -> Format.fprintf fmt "'%s'" s)) deps
LaunchHelper.js
+ (Format.pp_list ", " (fun fmt s -> Format.fprintf fmt "'%s'" s)) deps
let extrafiles () =
match ObjectFiles.get_current_package_name () with
View
15 tools/dependencies/launch_helper.js
@@ -17,18 +17,3 @@ if (process.version < min_node_version) {
process.exit(1);
}
-dependencies = dependencies.filter(function(dependency, index, array) {
- // console.log('Checking', dependency, '...');
- try {
- module.require(dependency);
- return false;
- } catch(e) {
- if (process.version < "v0.8.0") return true;
- return (e.code === 'MODULE_NOT_FOUND');
- }
-});
-
-if (dependencies.length > 0) {
- console.error(dependencies.length+' modules are missing.', 'Please run: npm install '+dependencies.join(' '));
- process.exit(1);
-}

0 comments on commit 8dce9ff

Please sign in to comment.