repl: don't override all internal repl defaults · nodejs/node@61e57e0 · GitHub
Skip to content

Commit 61e57e0

Browse files
committed
repl: don't override all internal repl defaults
The createInternalRepl() module accepts an options object as an argument. However, if one is provided, it overrides all of the default options. This commit applies the options object to the defaults, only changing the values that are explicitly set. PR-URL: #7826 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 9735acc commit 61e57e0

5 files changed

Lines changed: 19 additions & 6 deletions

File tree

lib/internal/repl.js

Lines changed: 4 additions & 3 deletions

test/parallel/test-repl-envvars.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Flags: --expose-internals
44

5-
require('../common');
5+
const common = require('../common');
66
const stream = require('stream');
77
const REPL = require('internal/repl');
88
const assert = require('assert');
@@ -46,6 +46,10 @@ function run(test) {
4646

4747
REPL.createInternalRepl(env, opts, function(err, repl) {
4848
if (err) throw err;
49+
50+
// The REPL registers 'module' and 'require' globals
51+
common.allowGlobals(repl.context.module, repl.context.require);
52+
4953
assert.equal(expected.terminal, repl.terminal,
5054
'Expected ' + inspect(expected) + ' with ' + inspect(env));
5155
assert.equal(expected.useColors, repl.useColors,

test/parallel/test-repl-history-perm.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const replHistoryPath = path.join(common.tmpDir, '.node_repl_history');
3535
const checkResults = common.mustCall(function(err, r) {
3636
if (err)
3737
throw err;
38+
39+
// The REPL registers 'module' and 'require' globals
40+
common.allowGlobals(r.context.module, r.context.require);
41+
3842
r.input.end();
3943
const stat = fs.statSync(replHistoryPath);
4044
assert.strictEqual(

test/parallel/test-repl-persistent-history.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ function runTest(assertCleaned) {
262262
throw err;
263263
}
264264

265+
// The REPL registers 'module' and 'require' globals
266+
common.allowGlobals(repl.context.module, repl.context.require);
267+
265268
repl.once('close', () => {
266269
if (repl._flushing) {
267270
repl.once('flushHistory', onClose);

test/parallel/test-repl-use-global.js

Lines changed: 3 additions & 2 deletions

0 commit comments

Comments
 (0)