diff --git a/lib/repl.js b/lib/repl.js index 3d0c367918256a..5db94641a3c3d1 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1479,16 +1479,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 6e3bca24e25932..bcaa39f6aa8215 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/,