Permalink
Browse files

Use narwhal/tusk/support module to determine compatibility with tusk

  • Loading branch information...
Tom Robinson
Tom Robinson committed Mar 11, 2010
1 parent ff03025 commit 380d126ae11ca48a433e3cf65ca12eae1ed495f7
Showing with 25 additions and 3 deletions.
  1. +1 −1 bin/tusk
  2. +1 −2 engines/rhino/bootstrap.js
  3. +6 −0 engines/rhino/lib/narwhal/tusk/support.js
  4. +17 −0 lib/narwhal/tusk/support.js
View
@@ -1,6 +1,6 @@
#!/usr/bin/env narwhal
-if (!system.supportsTusk)
+if (!require("narwhal/tusk/support").supportsEngine())
require("narwhal").ensureEngine("rhino");
require('narwhal/tusk').main(system.args);
@@ -109,8 +109,7 @@
evaluate: evaluate,
debug: debug,
verbose: verbose,
- setOptimizationLevel: setOptimizationLevel,
- supportsTusk: true
+ setOptimizationLevel: setOptimizationLevel
},
file: {
read: read,
@@ -0,0 +1,6 @@
+
+// -- tlrobinson Tom Robinson
+
+exports.supportsEngine = function() {
+ return true;
+}
@@ -0,0 +1,17 @@
+
+// -- tlrobinson Tom Robinson
+
+exports.supportsEngine = function() {
+ // deprecated
+ if (require("system").supportsTusk != undefined) {
+ require("narwhal").deprecated("system.supportsTusk deprecated in favor of supportsEngine() function in 'narwhal/tusk/support' module.");
+ return require("system").supportsTusk;
+ }
+
+ // attempt to feature detect the things needed by tusk
+ var hasHttp = false, hasUnzip = false;
+ try { hasHttp = !!require("http").open; } catch (e) {}
+ try { hasUnzip = !!require("zip").Unzip; } catch (e) {}
+
+ return hasHttp && hasUnzip;
+}

0 comments on commit 380d126

Please sign in to comment.