Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 380d126ae11ca48a433e3cf65ca12eae1ed495f7 1 parent ff03025
Tom Robinson authored
View
2  bin/tusk
@@ -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);
View
3  engines/rhino/bootstrap.js
@@ -109,8 +109,7 @@
evaluate: evaluate,
debug: debug,
verbose: verbose,
- setOptimizationLevel: setOptimizationLevel,
- supportsTusk: true
+ setOptimizationLevel: setOptimizationLevel
},
file: {
read: read,
View
6 engines/rhino/lib/narwhal/tusk/support.js
@@ -0,0 +1,6 @@
+
+// -- tlrobinson Tom Robinson
+
+exports.supportsEngine = function() {
+ return true;
+}
View
17 lib/narwhal/tusk/support.js
@@ -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;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.