diff --git a/lib/coffee-script.js b/lib/coffee-script.js index 12ca09e2..d67b745c 100755 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -47,7 +47,7 @@ while (root.parent) { root = root.parent; } - root.filename = fs.realpathSync(options.fileName || '.'); + root.filename = options.fileName ? fs.realpathSync(options.fileName) : '.'; if (root.moduleCache) { root.moduleCache = {}; } @@ -59,7 +59,7 @@ }; exports.eval = function(code, options) { var __dirname, __filename; - __filename = options.fileName; + __filename = module.filename = options.fileName; __dirname = path.dirname(__filename); return eval(compile(code, options)); }; diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 01710cd5..6c3b9c46 100755 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -58,7 +58,7 @@ exports.run = (code, options) -> while root.parent root = root.parent # Set the filename. - root.filename = fs.realpathSync options.fileName or '.' + root.filename = if options.fileName then fs.realpathSync(options.fileName) else '.' # Clear the module cache. root.moduleCache = {} if root.moduleCache # Compile. @@ -70,7 +70,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) -> - __filename = options.fileName + __filename = module.filename = options.fileName __dirname = path.dirname __filename eval compile code, options