diff --git a/lib/repl.js b/lib/repl.js index a0ff3b91451d74..cbf3889aba3663 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1477,16 +1477,16 @@ function defineDefaultCommands(repl) { this.displayPrompt(); } }); - - repl.defineCommand('editor', { - help: 'Enter editor mode', - action() { - if (!this.terminal) return; - _turnOnEditorMode(this); - this.outputStream.write( - '// Entering editor mode (^D to finish, ^C to cancel)\n'); - } - }); + if (repl.terminal) { + repl.defineCommand('editor', { + help: 'Enter editor mode', + action() { + _turnOnEditorMode(this); + this.outputStream.write( + '// Entering editor mode (^D to finish, ^C to cancel)\n'); + } + }); + } } function regexpEscape(s) { diff --git a/test/parallel/test-repl-save-load.js b/test/parallel/test-repl-save-load.js index 7d6f28548f7056..eff05a39203acd 100644 --- a/test/parallel/test-repl-save-load.js +++ b/test/parallel/test-repl-save-load.js @@ -61,7 +61,7 @@ assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'), '}' ]; const putIn = new ArrayStream(); - const replServer = repl.start('', putIn); + const replServer = repl.start({ terminal: true, stream: putIn }); putIn.run(['.editor']); putIn.run(cmds); diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 51c640de26e386..f0f04fa79c3602 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -439,7 +439,6 @@ const errorTests = [ expect: [ /\.break/, /\.clear/, - /\.editor/, /\.exit/, /\.help/, /\.load/,