1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Fixing require './foo' under --eval and REPL; issue 1035

This commit is contained in:
Trevor Burnham 2011-01-13 14:20:11 -05:00
parent 47e4f4dae1
commit 7815138386
2 changed files with 4 additions and 4 deletions

View file

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

View file

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