mirror of https://github.com/nodejs/node.git
repl: dont throw ENOENT on NODE_REPL_HISTORY_FILE
If you have no history file written to disk, but the environment variable set, `fs.readFileSync` will throw an ENOENT error, but there's nothing to convert. The converter should ignore ENOENT on that `fs.readFileSync` call. Fixes: https://github.com/nodejs/node/issues/2449 PR-URL: https://github.com/nodejs/node/pull/2451 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>pull/2451/merge
parent
291b310e21
commit
3849750a09
|
@ -122,8 +122,10 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
|
||||||
}
|
}
|
||||||
repl.history = repl.history.slice(-repl.historySize);
|
repl.history = repl.history.slice(-repl.historySize);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return ready(
|
if (err.code !== 'ENOENT') {
|
||||||
|
return ready(
|
||||||
new Error(`Could not parse history data in ${oldHistoryPath}.`));
|
new Error(`Could not parse history data in ${oldHistoryPath}.`));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ const fixtures = path.join(common.testDir, 'fixtures');
|
||||||
const historyFixturePath = path.join(fixtures, '.node_repl_history');
|
const historyFixturePath = path.join(fixtures, '.node_repl_history');
|
||||||
const historyPath = path.join(common.tmpDir, '.fixture_copy_repl_history');
|
const historyPath = path.join(common.tmpDir, '.fixture_copy_repl_history');
|
||||||
const oldHistoryPath = path.join(fixtures, 'old-repl-history-file.json');
|
const oldHistoryPath = path.join(fixtures, 'old-repl-history-file.json');
|
||||||
|
const enoentHistoryPath = path.join(fixtures, 'enoent-repl-history-file.json');
|
||||||
|
|
||||||
|
|
||||||
const tests = [{
|
const tests = [{
|
||||||
|
@ -76,6 +77,12 @@ const tests = [{
|
||||||
test: [UP],
|
test: [UP],
|
||||||
expected: [prompt, replDisabled, prompt]
|
expected: [prompt, replDisabled, prompt]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
env: { NODE_REPL_HISTORY: '',
|
||||||
|
NODE_REPL_HISTORY_FILE: enoentHistoryPath },
|
||||||
|
test: [UP],
|
||||||
|
expected: [prompt, replDisabled, prompt]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
env: { NODE_REPL_HISTORY: '',
|
env: { NODE_REPL_HISTORY: '',
|
||||||
NODE_REPL_HISTORY_FILE: oldHistoryPath },
|
NODE_REPL_HISTORY_FILE: oldHistoryPath },
|
||||||
|
|
Loading…
Reference in New Issue