Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated system/engine migration shims and added --strict mode for tra…

…cing deprecations.
  • Loading branch information...
commit c9b174a8f704ebf6b818655101b5a98152c46e1f 1 parent 744e94e
@kriskowal kriskowal authored
View
4 lib/narwhal.js
@@ -65,6 +65,10 @@ parser.option('-v', '--verbose', 'verbose')
.def(0)
.inc();
+parser.option('-s', '--strict', 'strict')
+ .help("strict mode: deprecations throw errors with tracebacks")
+ .set(true);
+
parser.option('-x', '--shebang', 'shebang')
.help('skip every line before the Unix #!shebang for non-Unix shebangs')
.set(true)
View
9 narwhal.js
@@ -18,14 +18,18 @@ if (modules.fs) {
}
// XXX: migration for the split between engine and system
+// is the engine splits system/engine
if (modules.engine) {
var engine = modules.engine;
for (var name in engine) {
system[name] = engine[name];
}
}
+// if the engine does not split system/engine
+modules.engine = modules.engine || modules.system;
// XXX: migration for the rename of evaluate to Module
system.evaluate = system.evaluate || system.Module;
+system.Module = system.Module || system.evaluate;
// XXX: migration step for deprecated engines
// the old system.evaluate accepts a tuple and
@@ -203,6 +207,11 @@ if (!wasVerbose && system.verbose) {
});
}
+// strict mode causes deprecation errors (as registered with the
+// narwhal/deprecation module) to throw errors so they can be
+// traced.
+modules.engine.strict = options.strict;
+
// find the program module and its prefix
var program;
if (system.args.length && !options.interactive && !options.main) {
View
6 packages/narwhal-lib/lib/narwhal/deprecated.js
@@ -1,12 +1,16 @@
+var ENGINE = require("engine");
+
/**
* Prints a deprecation warning to standard output, with
* terminal colors if possible.
* @param {String} warning
*/
exports.deprecated = function(warning) {
+ if (ENGINE.strict)
+ throw new Error("Deprecated:" + warning);
require("narwhal/term")
.stream
- .printError("\0yellow(Deprecated: "+warning+"\0)");
+ .printError("\0yellow(Deprecated: " + warning + "\0)");
}
Please sign in to comment.
Something went wrong with that request. Please try again.