From 4cd292622440ab01fd9b4765aba978b81dfc5fc7 Mon Sep 17 00:00:00 2001 From: Wes Brown Date: Tue, 22 Apr 2014 12:40:20 -0400 Subject: Correct issue where readline bombs out if there's no existing history file. --- js/node_readline.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/node_readline.js b/js/node_readline.js index f91bbaf..0585e0f 100644 --- a/js/node_readline.js +++ b/js/node_readline.js @@ -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 Date: Tue, 22 Apr 2014 12:44:26 -0400 Subject: Automatically install node modules if the directory doesn't exist. --- js/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/Makefile b/js/Makefile index 36b9caa..87afef1 100644 --- a/js/Makefile +++ b/js/Makefile @@ -6,7 +6,10 @@ SOURCES_LISP = env.js core.js stepA_more.js SOURCES = $(SOURCES_BASE) $(SOURCES_LISP) WEB_SOURCES = $(SOURCES:node_readline.js=josh_readline.js) -all: mal.js mal_web.js +all: node_modules mal.js mal_web.js + +node_modules: + npm install mal.js: $(SOURCES) echo "#!/usr/bin/env node" > $@ -- cgit v1.2.3