summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-02-21 15:33:46 +0100
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-02-28 05:21:07 +0100
commitdf43754fe1bf70042ae364f2365b42271468f102 (patch)
treecd7515deb8729c80d931fdd037187eee624aaf40
parent197690972c3cb8d193bfa3e1a99f3d8b4c414ee1 (diff)
downloadandroid-node-v8-df43754fe1bf70042ae364f2365b42271468f102.tar.gz
android-node-v8-df43754fe1bf70042ae364f2365b42271468f102.tar.bz2
android-node-v8-df43754fe1bf70042ae364f2365b42271468f102.zip
repl: hide editor mode if not used in a terminal
The editor mode is only useable when used as terminal. Hide it from the user in case the repl terminal option is not set. PR-URL: https://github.com/nodejs/node/pull/26240 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
-rw-r--r--lib/repl.js20
-rw-r--r--test/parallel/test-repl-save-load.js2
-rw-r--r--test/parallel/test-repl.js1
3 files changed, 11 insertions, 12 deletions
diff --git a/lib/repl.js b/lib/repl.js
index 3d0c367918..5db94641a3 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 7d6f28548f..eff05a3920 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 6e3bca24e2..bcaa39f6aa 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/,