| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1178,6 +1178,14 @@ Path to the file used to store the persistent REPL history. The default path is | |||
| 1178 | 1178 | `~/.node_repl_history`, which is overridden by this variable. Setting the value | |
| 1179 | 1179 | to an empty string (`''` or `' '`) disables persistent REPL history. | |
| 1180 | 1180 | ||
| 1181 | + ### `NODE_REPL_EXTERNAL_MODULE=file` | ||
| 1182 | + <!-- YAML | ||
| 1183 | + added: REPLACEME | ||
| 1184 | + --> | ||
| 1185 | + | ||
| 1186 | + Path to a Node.js module which will be loaded in place of the built-in REPL. | ||
| 1187 | + Overriding this value to an empty string (`''`) will use the built-in REPL. | ||
| 1188 | + | ||
| 1181 | 1189 | ### `NODE_TLS_REJECT_UNAUTHORIZED=value` | |
| 1182 | 1190 | ||
| 1183 | 1191 | If `value` equals `'0'`, certificate validation is disabled for TLS connections. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + console.log('42'); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const fixtures = require('../common/fixtures'); | ||
| 5 | + const { execSync } = require('child_process'); | ||
| 6 | + | ||
| 7 | + execSync(process.execPath, { | ||
| 8 | + encoding: 'utf8', | ||
| 9 | + stdio: 'inherit', | ||
| 10 | + env: { | ||
| 11 | + ...process.env, | ||
| 12 | + NODE_REPL_EXTERNAL_MODULE: fixtures.path('external-repl-module.js'), | ||
| 13 | + }, | ||
| 14 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + 42 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments