@@ -19,38 +19,44 @@ prepareMainThreadExecution(); |
19 | 19 |
|
20 | 20 | markBootstrapComplete(); |
21 | 21 |
|
22 | | -// --input-type flag not supported in REPL |
23 | | -if (getOptionValue('--input-type')) { |
24 | | - // If we can't write to stderr, we'd like to make this a noop, |
25 | | - // so use console.error. |
26 | | - console.error('Cannot specify --input-type for REPL'); |
27 | | - process.exit(1); |
28 | | -} |
| 22 | +if (process.env.NODE_REPL_EXTERNAL_MODULE) { |
| 23 | + require('internal/modules/cjs/loader') |
| 24 | + .Module |
| 25 | + ._load(process.env.NODE_REPL_EXTERNAL_MODULE, undefined, true); |
| 26 | +} else { |
| 27 | + // --input-type flag not supported in REPL |
| 28 | + if (getOptionValue('--input-type')) { |
| 29 | + // If we can't write to stderr, we'd like to make this a noop, |
| 30 | + // so use console.error. |
| 31 | + console.error('Cannot specify --input-type for REPL'); |
| 32 | + process.exit(1); |
| 33 | + } |
29 | 34 |
|
30 | | -console.log(`Welcome to Node.js ${process.version}.\n` + |
31 | | - 'Type ".help" for more information.'); |
| 35 | + console.log(`Welcome to Node.js ${process.version}.\n` + |
| 36 | + 'Type ".help" for more information.'); |
32 | 37 |
|
33 | | -const cliRepl = require('internal/repl'); |
34 | | -cliRepl.createInternalRepl(process.env, (err, repl) => { |
35 | | - if (err) { |
36 | | - throw err; |
37 | | - } |
38 | | - repl.on('exit', () => { |
39 | | - if (repl._flushing) { |
40 | | - repl.pause(); |
41 | | - return repl.once('flushHistory', () => { |
42 | | - process.exit(); |
43 | | - }); |
| 38 | + const cliRepl = require('internal/repl'); |
| 39 | + cliRepl.createInternalRepl(process.env, (err, repl) => { |
| 40 | + if (err) { |
| 41 | + throw err; |
44 | 42 | } |
45 | | - process.exit(); |
| 43 | + repl.on('exit', () => { |
| 44 | + if (repl._flushing) { |
| 45 | + repl.pause(); |
| 46 | + return repl.once('flushHistory', () => { |
| 47 | + process.exit(); |
| 48 | + }); |
| 49 | + } |
| 50 | + process.exit(); |
| 51 | + }); |
46 | 52 | }); |
47 | | -}); |
48 | | - |
49 | | -// If user passed '-e' or '--eval' along with `-i` or `--interactive`, |
50 | | -// evaluate the code in the current context. |
51 | | -if (getOptionValue('[has_eval_string]')) { |
52 | | - evalScript('[eval]', |
53 | | - getOptionValue('--eval'), |
54 | | - getOptionValue('--inspect-brk'), |
55 | | - getOptionValue('--print')); |
| 53 | + |
| 54 | + // If user passed '-e' or '--eval' along with `-i` or `--interactive`, |
| 55 | + // evaluate the code in the current context. |
| 56 | + if (getOptionValue('[has_eval_string]')) { |
| 57 | + evalScript('[eval]', |
| 58 | + getOptionValue('--eval'), |
| 59 | + getOptionValue('--inspect-brk'), |
| 60 | + getOptionValue('--print')); |
| 61 | + } |
56 | 62 | } |