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

Decouple --require from individual file compilations #1045

Merged
2 commits merged into from
Jan 15, 2011
Merged

Decouple --require from individual file compilations #1045

2 commits merged into from
Jan 15, 2011

Conversation

TrevorBurnham
Copy link
Collaborator

Currently, coffee -r "./foo.coffee" (in conjunction with -e or -c) will require foo.coffee each time a file is compiled. In addition to the obvious inefficiency, there's a loss of functionality: You can't use the flag to require a file before entering the REPL.

This patch fixes that; coffee -r "./foo.coffee" now requires foo.coffee and then enters the REPL. It also (temporarily) changes module.filename before doing the require; it feels a little kludgy, but it means that you can write

coffee -epr ./ext '1 + 1'

instead of having to specify ./ext.coffee or ./ext.js, thus better mirroring the require syntax.

Trevor Burnham added 2 commits January 13, 2011 14:20
This change allows files to be `--require`d before entering the REPL. It's also
an opimization, since files are `--require`d only once, rather than being
required again every time a file is compiled.

A secondary change is that `module.filename` is temporarily modified. This is
somewhat less aesthetically appealing than the old approach of using
fs.realpathSync, but it allows you to run `coffee -r ./foo` rather than having
to write `coffee -r ./foo.coffee`, since Node does not accept absolute paths
without a file extension.
@TrevorBurnham
Copy link
Collaborator Author

Also see my patch here for issue 1035, which this stemmed from.

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

Successfully merging this pull request may close these issues.

1 participant