Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set process.argv[0] to 'coffee' when using coffee foo.coffee #1303

Merged
merged 2 commits into from
Apr 30, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/coffee-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
while (root.parent) {
root = root.parent;
}
process.argv[0] = 'coffee';
root.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
if (root.moduleCache) {
root.moduleCache = {};
Expand All @@ -65,6 +66,7 @@
};
exports.eval = function(code, options) {
var __dirname, __filename;
process.argv[0] = 'coffee';
__filename = module.filename = process.argv[1] = options.filename;
__dirname = path.dirname(__filename);
return eval(compile(code, options));
Expand Down
5 changes: 5 additions & 0 deletions src/coffee-script.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ exports.run = (code, options) ->
root = module
while root.parent
root = root.parent

# Set the process command to `coffee`
process.argv[0] = 'coffee'

# Set the filename.
root.filename = process.argv[1] =
if options.filename then fs.realpathSync(options.filename) else '.'
Expand All @@ -78,6 +82,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) ->
process.argv[0] = 'coffee'
__filename = module.filename = process.argv[1] = options.filename
__dirname = path.dirname __filename
eval compile code, options
Expand Down