mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
More accurately emulating node's REPL behaviour with regard to _
assignment. Also addresses `i for i in [1..3]` regression introduced by
fff4c9c672 and noticed by @satyr
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
}
|
||||
};
|
||||
exports.eval = function(code, options) {
|
||||
var js, k, o, r, sandbox, v, _, _i, _len, _module, _ref2, _ref3, _require;
|
||||
var js, k, o, r, returnValue, sandbox, v, _, _i, _len, _module, _ref2, _ref3, _require;
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
@@ -109,12 +109,13 @@
|
||||
o[k] = v;
|
||||
}
|
||||
o.bare = true;
|
||||
js = compile("(" + code + "\n)", o);
|
||||
_ = Script.runInContext(js, sandbox);
|
||||
if (_ != null) {
|
||||
js = compile("_=(" + code + "\n)", o);
|
||||
_ = sandbox._;
|
||||
returnValue = Script.runInContext(js, sandbox);
|
||||
if (returnValue === void 0) {
|
||||
sandbox._ = _;
|
||||
}
|
||||
return _;
|
||||
return returnValue;
|
||||
};
|
||||
lexer = new Lexer;
|
||||
parser.lexer = {
|
||||
|
||||
@@ -101,10 +101,11 @@ exports.eval = (code, options = {}) ->
|
||||
o = {}
|
||||
o[k] = v for own k, v of options
|
||||
o.bare = on # ensure return value
|
||||
js = compile "(#{code}\n)", o
|
||||
_ = Script.runInContext js, sandbox
|
||||
sandbox._ = _ if _?
|
||||
_
|
||||
js = compile "_=(#{code}\n)", o
|
||||
_ = sandbox._
|
||||
returnValue = Script.runInContext js, sandbox
|
||||
sandbox._ = _ if returnValue is undefined
|
||||
returnValue
|
||||
|
||||
# Instantiate a Lexer for our use here.
|
||||
lexer = new Lexer
|
||||
|
||||
Reference in New Issue
Block a user