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

process.argv #1087

Closed
dvv opened this issue Jan 25, 2011 · 3 comments
Closed

process.argv #1087

dvv opened this issue Jan 25, 2011 · 3 comments

Comments

@dvv
Copy link

dvv commented Jan 25, 2011

Hi!

Running coffee test.coffee gives process.argv == [node-path, coffee-path] thus info about the script being run is lost.

Any kludge hope to cope?

TIA,
--Vladimir

@dvv
Copy link
Author

dvv commented Jan 25, 2011

The workaround is to

process.argv[0] = process.argv[1]
process.argv[1] = __filename

@TrevorBurnham
Copy link
Collaborator

I've submitted a patch to fix this by setting process.argv[1] to __filename within coffee. See the pull request at 1092.

Not sure about process.argv[0], though... I think it's best to keep that as 'node'. In principle, CoffeeScript code could be run under other CommonJS frameworks that define process.argv, so pinging process.argv[0] should tell you which environment you're running under. Don't you think?

With the patch, process.argv should be the same whether you run

coffee foo.coffee arg1 arg2

or

coffee -c foo.coffee
node foo.js arg1 arg2

which seems quite sensible to me.

@jashkenas
Copy link
Owner

Thanks, Trevor -- I've merged your fix to "stable" (and soon to "master") at abfc993 ... closing the ticket.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants