REPL blank line fix

This commit is contained in:
Michael Ficarra 2011-06-02 01:34:55 -04:00
parent 10ec1a659f
commit 35c2a72ad2
2 changed files with 6 additions and 2 deletions

View File

@ -64,6 +64,9 @@
if (options == null) {
options = {};
}
if (!(code = code.trim())) {
return;
}
sandbox = options.sandbox;
if (!sandbox) {
sandbox = {
@ -88,7 +91,7 @@
o[k] = v;
}
o.bare = true;
js = compile("_=(" + (code.trim()) + "\n)", o);
js = compile("_=(" + code + "\n)", o);
return vm.runInNewContext(js, sandbox, sandbox.__filename);
};
lexer = new Lexer;

View File

@ -77,6 +77,7 @@ exports.run = (code, options) ->
# Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
# The CoffeeScript REPL uses this to run the input.
exports.eval = (code, options = {}) ->
return unless code = code.trim()
sandbox = options.sandbox
unless sandbox
sandbox =
@ -89,7 +90,7 @@ exports.eval = (code, options = {}) ->
sandbox.__dirname = path.dirname sandbox.__filename
o = {}; o[k] = v for k, v of options
o.bare = on # ensure return value
js = compile "_=(#{code.trim()}\n)", o
js = compile "_=(#{code}\n)", o
vm.runInNewContext js, sandbox, sandbox.__filename
# Instantiate a Lexer for our use here.