diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2017-06-22 18:47:44 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-02-12 14:58:55 +0100 |
commit | 60c9ad797994e544af21ce991dce2c3360ae1801 (patch) | |
tree | ec0edc4a09b201f3bd522998e2f8feded7b4e28b /lib/internal/repl.js | |
parent | 1a5f6705c611bc9376e8cd49ff2b03b08c3b97b0 (diff) | |
download | android-node-v8-60c9ad797994e544af21ce991dce2c3360ae1801.tar.gz android-node-v8-60c9ad797994e544af21ce991dce2c3360ae1801.tar.bz2 android-node-v8-60c9ad797994e544af21ce991dce2c3360ae1801.zip |
repl: remove deprecated NODE_REPL_HISTORY_FILE
PR-URL: https://github.com/nodejs/node/pull/13876
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib/internal/repl.js')
-rw-r--r-- | lib/internal/repl.js | 58 |
1 files changed, 7 insertions, 51 deletions
diff --git a/lib/internal/repl.js b/lib/internal/repl.js index 76412c3b11..a852f87bc8 100644 --- a/lib/internal/repl.js +++ b/lib/internal/repl.js @@ -34,7 +34,7 @@ function createInternalRepl(env, opts, cb) { if (parseInt(env.NODE_NO_READLINE)) { opts.terminal = false; } - // the "dumb" special terminal, as defined by terminfo, doesn't support + // The "dumb" special terminal, as defined by terminfo, doesn't support // ANSI color control codes. // see http://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials if (parseInt(env.NODE_DISABLE_COLORS) || env.TERM === 'dumb') { @@ -61,17 +61,15 @@ function createInternalRepl(env, opts, cb) { const repl = REPL.start(opts); if (opts.terminal) { - return setupHistory(repl, env.NODE_REPL_HISTORY, - env.NODE_REPL_HISTORY_FILE, cb); + return setupHistory(repl, env.NODE_REPL_HISTORY, cb); } repl._historyPrev = _replHistoryMessage; cb(null, repl); } -function setupHistory(repl, historyPath, oldHistoryPath, ready) { - // Empty string disables persistent history. - +function setupHistory(repl, historyPath, ready) { + // Empty string disables persistent history if (typeof historyPath === 'string') historyPath = historyPath.trim(); @@ -131,50 +129,8 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) { if (data) { repl.history = data.split(/[\n\r]+/, repl.historySize); - } else if (oldHistoryPath === historyPath) { - // If pre-v3.0, the user had set NODE_REPL_HISTORY_FILE to - // ~/.node_repl_history, warn the user about it and proceed. - _writeToOutput( - repl, - '\nThe old repl history file has the same name and location as ' + - `the new one i.e., ${historyPath} and is empty.\nUsing it as is.\n`); - - } else if (oldHistoryPath) { - let threw = false; - try { - // Pre-v3.0, repl history was stored as JSON. - // Try and convert it to line separated history. - const oldReplJSONHistory = fs.readFileSync(oldHistoryPath, 'utf8'); - - // Only attempt to use the history if there was any. - if (oldReplJSONHistory) repl.history = JSON.parse(oldReplJSONHistory); - - if (Array.isArray(repl.history)) { - repl.history = repl.history.slice(0, repl.historySize); - } else { - threw = true; - _writeToOutput( - repl, - '\nError: The old history file data has to be an Array.\n' + - 'REPL session history will not be persisted.\n'); - } - } catch (err) { - // Cannot open or parse history file. - // Don't crash, just don't persist history. - threw = true; - const type = err instanceof SyntaxError ? 'parse' : 'open'; - _writeToOutput(repl, `\nError: Could not ${type} old history file.\n` + - 'REPL session history will not be persisted.\n'); - } - if (!threw) { - // Grab data from the older pre-v3.0 JSON NODE_REPL_HISTORY_FILE format. - _writeToOutput( - repl, - '\nConverted old JSON repl history to line-separated history.\n' + - `The new repl history file can be found at ${historyPath}.\n`); - } else { - repl.history = []; - } + } else { + repl.history = []; } fs.open(historyPath, 'r+', onhandle); @@ -188,7 +144,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) { repl._historyHandle = hnd; repl.on('line', online); - // reading the file data out erases it + // Reading the file data out erases it repl.once('flushHistory', function() { repl.resume(); ready(null, repl); |