Merge pull request #2725 from mintplant/repl-fix

Fix REPL crashing on execution error
This commit is contained in:
Michael Ficarra
2013-02-26 08:20:36 -08:00
2 changed files with 5 additions and 5 deletions

View File

@@ -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));
}
};

View File

@@ -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