1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Keep REPL running on runtime errors

This commit is contained in:
Demian Ferreiro 2013-03-11 21:31:17 -03:00
parent 20d98c7106
commit 45bcd9fa2f
3 changed files with 10 additions and 4 deletions

View file

@ -24,11 +24,11 @@
bare: true, bare: true,
locals: Object.keys(context) locals: Object.keys(context)
}); });
return cb(null, vm.runInContext(js, context, filename));
} catch (_error) { } catch (_error) {
err = _error; err = _error;
console.log(prettyErrorMessage(err, filename, input, true)); return cb(prettyErrorMessage(err, filename, input, true));
} }
return cb(null, vm.runInContext(js, context, filename));
} }
}; };

View file

@ -23,9 +23,9 @@ replDefaults =
new Assign (new Value new Literal '_'), ast, '=' new Assign (new Value new Literal '_'), ast, '='
] ]
js = ast.compile bare: yes, locals: Object.keys(context) js = ast.compile bare: yes, locals: Object.keys(context)
catch err
console.log prettyErrorMessage err, filename, input, yes
cb null, vm.runInContext(js, context, filename) cb null, vm.runInContext(js, context, filename)
catch err
cb prettyErrorMessage(err, filename, input, yes)
addMultilineHandler = (repl) -> addMultilineHandler = (repl) ->
{rli, inputStream, outputStream} = repl {rli, inputStream, outputStream} = repl

View file

@ -91,3 +91,9 @@ testRepl "existential assignment of previously declared variable", (input, outpu
input.emitLine 'a = null' input.emitLine 'a = null'
input.emitLine 'a ?= 42' input.emitLine 'a ?= 42'
eq '42', output.lastWrite() eq '42', output.lastWrite()
testRepl "keeps running after runtime error", (input, output) ->
input.emitLine 'a = b'
eq 0, output.lastWrite().indexOf 'ReferenceError: b is not defined'
input.emitLine 'a'
eq 'undefined', output.lastWrite()