1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-09 18:06:35 +03:00

Correct issue where readline bombs out if there's no existing history file.

This commit is contained in:
Wes Brown 2014-04-22 12:40:20 -04:00
parent b3402a82d3
commit 4cd2926224

View File

@ -20,7 +20,10 @@ exports.readline = rlwrap.readline = function(prompt) {
if (!rl_history_loaded) {
rl_history_loaded = true;
var lines = fs.readFileSync(HISTORY_FILE).toString().split("\n");
var lines = [];
if (fs.existsSync(HISTORY_FILE)) {
lines = fs.readFileSync(HISTORY_FILE).toString().split("\n");
}
// Max of 2000 lines
lines = lines.slice(Math.max(lines.length - 2000, 0));
for (var i=0; i<lines.length; i++) {