Skip to content

Commit 2e2fce0

Browse files
committed
repl: fix persistent history and env variable name
Issue #1575 did introduce a check for options.terminal but this variable wasn't able to get truthy, which in turn broke persistent history completely. This changes the variable to get truthy on true terminals. Additionally, the docs and the code did differ on which environment variable was used for history. This changes the code to use NODE_REPL_HISTORY_FILE. PR-URL: #1593 Reviewed-By: Chris Dickinson <[email protected]>
1 parent 02388db commit 2e2fce0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/internal/repl.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ module.paths = require('module')._nodeModulePaths(module.filename);
2626

2727
function createRepl(env, cb) {
2828
const opts = {
29-
useGlobal: true,
30-
ignoreUndefined: false
29+
ignoreUndefined: false,
30+
terminal: process.stdout.isTTY,
31+
useGlobal: true
3132
};
3233

3334
if (parseInt(env.NODE_NO_READLINE)) {
@@ -57,8 +58,8 @@ function createRepl(env, cb) {
5758
}
5859

5960
const repl = REPL.start(opts);
60-
if (opts.terminal && env.NODE_REPL_HISTORY_PATH) {
61-
return setupHistory(repl, env.NODE_REPL_HISTORY_PATH, cb);
61+
if (opts.terminal && env.NODE_REPL_HISTORY_FILE) {
62+
return setupHistory(repl, env.NODE_REPL_HISTORY_FILE, cb);
6263
}
6364
repl._historyPrev = _replHistoryMessage;
6465
cb(null, repl);
@@ -158,7 +159,7 @@ function _replHistoryMessage() {
158159
if (this.history.length === 0) {
159160
this._writeToOutput(
160161
'\nPersistent history support disabled. ' +
161-
'Set the NODE_REPL_HISTORY_PATH environment variable to ' +
162+
'Set the NODE_REPL_HISTORY_FILE environment variable to ' +
162163
'a valid, user-writable path to enable.\n'
163164
);
164165
this._refreshLine();

0 commit comments

Comments
 (0)