Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGus Caplan <me@gus.host>2019-09-27 01:58:49 +0300
committerGus Caplan <me@gus.host>2019-10-11 22:33:40 +0300
commitc0305af2c4aba6d6ecd39eb100a59998d87ddc69 (patch)
treea83ae9edb6421e14160ed8a3ba60164979040145 /lib/internal/main
parent06f6d662f679ee04679d97ecd5087e6f17268141 (diff)
repl: check for NODE_REPL_EXTERNAL_MODULE
PR-URL: https://github.com/nodejs/node/pull/29778 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'lib/internal/main')
-rw-r--r--lib/internal/main/repl.js66
1 files changed, 36 insertions, 30 deletions
diff --git a/lib/internal/main/repl.js b/lib/internal/main/repl.js
index 93b932f0bdd..693b7048a37 100644
--- a/lib/internal/main/repl.js
+++ b/lib/internal/main/repl.js
@@ -19,38 +19,44 @@ prepareMainThreadExecution();
markBootstrapComplete();
-// --input-type flag not supported in REPL
-if (getOptionValue('--input-type')) {
- // If we can't write to stderr, we'd like to make this a noop,
- // so use console.error.
- console.error('Cannot specify --input-type for REPL');
- process.exit(1);
-}
+if (process.env.NODE_REPL_EXTERNAL_MODULE) {
+ require('internal/modules/cjs/loader')
+ .Module
+ ._load(process.env.NODE_REPL_EXTERNAL_MODULE, undefined, true);
+} else {
+ // --input-type flag not supported in REPL
+ if (getOptionValue('--input-type')) {
+ // If we can't write to stderr, we'd like to make this a noop,
+ // so use console.error.
+ console.error('Cannot specify --input-type for REPL');
+ process.exit(1);
+ }
-console.log(`Welcome to Node.js ${process.version}.\n` +
- 'Type ".help" for more information.');
+ console.log(`Welcome to Node.js ${process.version}.\n` +
+ 'Type ".help" for more information.');
-const cliRepl = require('internal/repl');
-cliRepl.createInternalRepl(process.env, (err, repl) => {
- if (err) {
- throw err;
- }
- repl.on('exit', () => {
- if (repl._flushing) {
- repl.pause();
- return repl.once('flushHistory', () => {
- process.exit();
- });
+ const cliRepl = require('internal/repl');
+ cliRepl.createInternalRepl(process.env, (err, repl) => {
+ if (err) {
+ throw err;
}
- process.exit();
+ repl.on('exit', () => {
+ if (repl._flushing) {
+ repl.pause();
+ return repl.once('flushHistory', () => {
+ process.exit();
+ });
+ }
+ process.exit();
+ });
});
-});
-
-// If user passed '-e' or '--eval' along with `-i` or `--interactive`,
-// evaluate the code in the current context.
-if (getOptionValue('[has_eval_string]')) {
- evalScript('[eval]',
- getOptionValue('--eval'),
- getOptionValue('--inspect-brk'),
- getOptionValue('--print'));
+
+ // If user passed '-e' or '--eval' along with `-i` or `--interactive`,
+ // evaluate the code in the current context.
+ if (getOptionValue('[has_eval_string]')) {
+ evalScript('[eval]',
+ getOptionValue('--eval'),
+ getOptionValue('--inspect-brk'),
+ getOptionValue('--print'));
+ }
}