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:
parent
20d98c7106
commit
45bcd9fa2f
3 changed files with 10 additions and 4 deletions
|
@ -24,11 +24,11 @@
|
|||
bare: true,
|
||||
locals: Object.keys(context)
|
||||
});
|
||||
return cb(null, vm.runInContext(js, context, filename));
|
||||
} catch (_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));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ replDefaults =
|
|||
new Assign (new Value new Literal '_'), ast, '='
|
||||
]
|
||||
js = ast.compile bare: yes, locals: Object.keys(context)
|
||||
cb null, vm.runInContext(js, context, filename)
|
||||
catch err
|
||||
console.log prettyErrorMessage err, filename, input, yes
|
||||
cb null, vm.runInContext(js, context, filename)
|
||||
cb prettyErrorMessage(err, filename, input, yes)
|
||||
|
||||
addMultilineHandler = (repl) ->
|
||||
{rli, inputStream, outputStream} = repl
|
||||
|
|
|
@ -91,3 +91,9 @@ testRepl "existential assignment of previously declared variable", (input, outpu
|
|||
input.emitLine 'a = null'
|
||||
input.emitLine 'a ?= 42'
|
||||
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()
|
||||
|
|
Loading…
Add table
Reference in a new issue