readline: fix behaviour of Interface plugged to a non-terminal output

Fixes: https://github.com/nodejs/node/issues/36773

PR-URL: https://github.com/nodejs/node/pull/36774
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Antoine du Hamel committed 2021-01-06 18:45:16 +01:00
1 parent 9d35b92c73
commit fffdaeb4c9
2 files changed
+10 -3

No files matched your search

+3 -3
View File
@@ -282,9 +282,6 @@ function Interface(input, output, completer, terminal) {
input.on('keypress', onkeypress);
input.on('end', ontermend);
// Current line
this.line = '';
this._setRawMode(true);
this.terminal = true;
@@ -300,6 +297,9 @@ function Interface(input, output, completer, terminal) {
self.once('close', onSelfCloseWithTerminal);
}
// Current line
this.line = '';
input.resume();
}
+7
View File
@@ -0,0 +1,7 @@
'use strict';
const common = require('../common');
const repl = require('repl');
const r = repl.start({ terminal: false });
r.setupHistory('/nonexistent/file', common.mustSucceed());
process.stdin.unref?.();