Make the REPL *CLI* use the global context so as to be consistent with the node REPL CLI.

Make the REPL *CLI* use the global context so as to (a) be consistent
with the `node` REPL CLI and, therefore, (b) make packages that modify
native prototypes (such as 'colors' and 'sugar') work as expected.

Note that, by contrast, programmatic use (`require 'repl'`) will
continue to default to a NON-global context - again, consistent with
node's behavior.
This commit is contained in:
Michael Klement
2013-09-03 17:27:13 -04:00
parent 1765a7ae0c
commit fceff1729c
2 changed files with 18 additions and 11 deletions

View File

@@ -53,8 +53,11 @@
optionParser = null;
exports.run = function() {
var literals, source, _i, _len, _results;
var literals, replCliOpts, source, _i, _len, _results;
parseOptions();
replCliOpts = {
useGlobal: true
};
if (opts.nodejs) {
return forkNode();
}
@@ -65,7 +68,7 @@
return version();
}
if (opts.interactive) {
return require('./repl').start();
return require('./repl').start(replCliOpts);
}
if (opts.watch && !fs.watch) {
return printWarn("The --watch feature depends on Node v0.6.0+. You are running " + process.version + ".");
@@ -77,7 +80,7 @@
return compileScript(null, sources[0]);
}
if (!sources.length) {
return require('./repl').start();
return require('./repl').start(replCliOpts);
}
literals = opts.run ? sources.splice(1) : [];
process.argv = process.argv.slice(0, 2).concat(literals);