Fixing --eval; see issue 820

This commit is contained in:
Trevor Burnham 2010-10-28 22:18:11 -04:00
parent 6d8126e498
commit 776b1b723e
4 changed files with 11 additions and 4 deletions

View File

@ -40,7 +40,11 @@
while (root.parent) {
root = root.parent;
}
root.filename = fs.realpathSync(options.fileName);
if (options.fileName.length > 0) {
root.filename = fs.realpathSync(options.fileName);
} else {
root.filename = fs.realpathSync('.');
}
if (root.moduleCache) {
root.moduleCache = {};
}

View File

@ -30,7 +30,7 @@
return compileStdio();
}
if (opts.eval) {
return compileScript('console', sources[0]);
return compileScript('', sources[0]);
}
if (!sources.length) {
return require('./repl');

View File

@ -53,7 +53,10 @@ exports.run = (code, options) ->
while root.parent
root = root.parent
# Set the filename
root.filename = fs.realpathSync options.fileName
if options.fileName.length > 0
root.filename = fs.realpathSync options.fileName
else
root.filename = fs.realpathSync '.' # run eval code in working directory
# Clear the module cache
root.moduleCache = {} if root.moduleCache
# Compile

View File

@ -57,7 +57,7 @@ exports.run = ->
return version() if opts.version
return require './repl' if opts.interactive
return compileStdio() if opts.stdio
return compileScript 'console', sources[0] if opts.eval
return compileScript '', sources[0] if opts.eval
return require './repl' unless sources.length
separator = sources.indexOf '--'
flags = []