}
if (data) {
- repl.history = data.split(/[\n\r]+/).slice(-repl.historySize);
+ repl.history = data.split(/[\n\r]+/, repl.historySize);
} else if (oldHistoryPath) {
// Grab data from the older pre-v3.0 JSON NODE_REPL_HISTORY_FILE format.
repl._writeToOutput(
if (!Array.isArray(repl.history)) {
throw new Error('Expected array, got ' + typeof repl.history);
}
- repl.history = repl.history.slice(-repl.historySize);
+ repl.history = repl.history.slice(0, repl.historySize);
} catch (err) {
if (err.code !== 'ENOENT') {
return ready(
expected: [prompt, prompt + '\'42\'', prompt + '\'=^.^=\'', '\'=^.^=\'\n',
prompt]
},
+{
+ env: { NODE_REPL_HISTORY: historyPath,
+ NODE_REPL_HISTORY_SIZE: 1 },
+ test: [UP, UP, CLEAR],
+ expected: [prompt, prompt + '\'you look fabulous today\'', prompt]
+},
+{
+ env: { NODE_REPL_HISTORY_FILE: oldHistoryPath,
+ NODE_REPL_HISTORY_SIZE: 1 },
+ test: [UP, UP, UP, CLEAR],
+ expected: [prompt, convertMsg, prompt, prompt + '\'=^.^=\'', prompt]
+},
{ // Make sure this is always the last test, since we change os.homedir()
before: function mockHomedirFailure() {
// Mock os.homedir() failure