diff --git a/lib/coffee-script.js b/lib/coffee-script.js index dc9e65c4..1780af97 100755 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -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 = {}; } diff --git a/lib/command.js b/lib/command.js index 2eb7c03b..e7631238 100644 --- a/lib/command.js +++ b/lib/command.js @@ -30,7 +30,7 @@ return compileStdio(); } if (opts.eval) { - return compileScript('console', sources[0]); + return compileScript('', sources[0]); } if (!sources.length) { return require('./repl'); diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index dc26a5fe..c75728d5 100755 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -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 diff --git a/src/command.coffee b/src/command.coffee index d41d6eb8..cd0f9ac4 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -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 = []