diff --git a/lib/coffee-script.js b/lib/coffee-script.js index 40fa4dec..04620e18 100755 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -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; diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 0475075b..9c6c2e6d 100755 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -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.