Skip to content
This repository
Browse code

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

…cing deprecations.
  • Loading branch information...
commit c9b174a8f704ebf6b818655101b5a98152c46e1f 1 parent 744e94e
Kris Kowal kriskowal authored
4 lib/narwhal.js
@@ -65,6 +65,10 @@ parser.option('-v', '--verbose', 'verbose')
65 65 .def(0)
66 66 .inc();
67 67
  68 +parser.option('-s', '--strict', 'strict')
  69 + .help("strict mode: deprecations throw errors with tracebacks")
  70 + .set(true);
  71 +
68 72 parser.option('-x', '--shebang', 'shebang')
69 73 .help('skip every line before the Unix #!shebang for non-Unix shebangs')
70 74 .set(true)
9 narwhal.js
@@ -18,14 +18,18 @@ if (modules.fs) {
18 18 }
19 19
20 20 // XXX: migration for the split between engine and system
  21 +// is the engine splits system/engine
21 22 if (modules.engine) {
22 23 var engine = modules.engine;
23 24 for (var name in engine) {
24 25 system[name] = engine[name];
25 26 }
26 27 }
  28 +// if the engine does not split system/engine
  29 +modules.engine = modules.engine || modules.system;
27 30 // XXX: migration for the rename of evaluate to Module
28 31 system.evaluate = system.evaluate || system.Module;
  32 +system.Module = system.Module || system.evaluate;
29 33
30 34 // XXX: migration step for deprecated engines
31 35 // the old system.evaluate accepts a tuple and
@@ -203,6 +207,11 @@ if (!wasVerbose && system.verbose) {
203 207 });
204 208 }
205 209
  210 +// strict mode causes deprecation errors (as registered with the
  211 +// narwhal/deprecation module) to throw errors so they can be
  212 +// traced.
  213 +modules.engine.strict = options.strict;
  214 +
206 215 // find the program module and its prefix
207 216 var program;
208 217 if (system.args.length && !options.interactive && !options.main) {
6 packages/narwhal-lib/lib/narwhal/deprecated.js
... ... @@ -1,12 +1,16 @@
1 1
  2 +var ENGINE = require("engine");
  3 +
2 4 /**
3 5 * Prints a deprecation warning to standard output, with
4 6 * terminal colors if possible.
5 7 * @param {String} warning
6 8 */
7 9 exports.deprecated = function(warning) {
  10 + if (ENGINE.strict)
  11 + throw new Error("Deprecated:" + warning);
8 12 require("narwhal/term")
9 13 .stream
10   - .printError("\0yellow(Deprecated: "+warning+"\0)");
  14 + .printError("\0yellow(Deprecated: " + warning + "\0)");
11 15 }
12 16

0 comments on commit c9b174a

Please sign in to comment.
Something went wrong with that request. Please try again.