diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-23 22:03:45 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-23 22:03:45 -0500 |
| commit | e18f93f50711d475c407243c94d26daae5e814cc (patch) | |
| tree | 171535dbe0375e22e0e2de44c6f8012e14f5bd42 /js | |
| parent | 6301e0b6374cecc5599665be14d6ddc6a31ce1e8 (diff) | |
| parent | e47ddca2f8d80145386a377fc81a738d89c46cf0 (diff) | |
| download | mal-e18f93f50711d475c407243c94d26daae5e814cc.tar.gz mal-e18f93f50711d475c407243c94d26daae5e814cc.zip | |
Merge commit 'e47ddca2f8d80145386a377fc81a738d89c46cf0'
Diffstat (limited to 'js')
| -rw-r--r-- | js/Makefile | 5 | ||||
| -rw-r--r-- | js/node_readline.js | 5 |
2 files changed, 8 insertions, 2 deletions
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" > $@ 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<lines.length; i++) { |
