From 29ab97d58da87ed1e01849a833a8f146d5eb0886 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Thu, 14 Oct 2010 08:55:51 -0700 Subject: [PATCH] don't try to run a non-existent file --- lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/index.js b/lib/index.js index cd87e77..e81690b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -133,6 +133,15 @@ function pausingRepl(fn) { } function runFile(filename, callback) { + // check if file exists. might not have been saved. + try { + fs.statSync(filename) + } catch (e) { + _repl.stream.write('nothing to run\n') + callback() + return + } + var Script = process.binding('evals').Script , evalcx = Script.runInContext , read = fs.createReadStream(filename)