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

Commit 698bf2e

Browse files
cjihrigMylesBorins
authored andcommitted
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 02e8187 commit 698bf2e

4 files changed

Lines changed: 19 additions & 4 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: 6 additions & 0 deletions

0 commit comments

Comments
 (0)