mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Merge pull request #2725 from mintplant/repl-fix
Fix REPL crashing on execution error
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
var js;
|
||||
input = input.replace(/\uFF00/g, '\n');
|
||||
input = input.replace(/(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, '$1$2$3');
|
||||
if (/^\s*$/.test(input)) {
|
||||
if (/^(\()?\s*(\n\))?$/.test(input)) {
|
||||
return cb(null);
|
||||
}
|
||||
try {
|
||||
@@ -24,10 +24,10 @@
|
||||
filename: filename,
|
||||
bare: true
|
||||
});
|
||||
return cb(null, vm.runInContext(js, context, filename));
|
||||
} catch (err) {
|
||||
cb(err);
|
||||
return cb(err);
|
||||
}
|
||||
return cb(null, vm.runInContext(js, context, filename));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ replDefaults =
|
||||
# strip single-line comments
|
||||
input = input.replace /(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, '$1$2$3'
|
||||
# empty command
|
||||
return cb null if /^\s*$/.test input
|
||||
return cb null if /^(\s*|\(\s*\))$/.test input
|
||||
# TODO: fix #1829: pass in-scope vars and avoid accidentally shadowing them by omitting those declarations
|
||||
try
|
||||
js = CoffeeScript.compile "_=(#{input}\n)", {filename, bare: yes}
|
||||
cb null, vm.runInContext(js, context, filename)
|
||||
catch err
|
||||
cb err
|
||||
cb null, vm.runInContext(js, context, filename)
|
||||
|
||||
addMultilineHandler = (repl) ->
|
||||
{rli, inputStream, outputStream} = repl
|
||||
|
||||
Reference in New Issue
Block a user