-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[CS2] Un-prefer global #4543
[CS2] Un-prefer global #4543
Conversation
…uld try to run the locally-installed module if it exists, or the global version otherwise
bin/cake
Outdated
path.join(path.dirname(fs.realpathSync(__filename)), '../lib/coffeescript') | ||
]; | ||
|
||
for (var i = 0; i < 4; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a hard coded 4
rather than potentialPaths.length
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to be optimized, though I can see how this comes across as overkill. I toyed with a series of if statements to avoid even the unnecessary path manipulation lines, but testing didn't show a difference. I can make this more idiomatic if you think it's silly to hard-code the length to save 1ms.
bin/cake
Outdated
path.join(process.cwd(), 'node_modules/coffeescript/lib/coffeescript'), | ||
path.join(process.cwd(), 'node_modules/coffeescript/lib/coffee-script'), | ||
path.join(process.cwd(), 'node_modules/coffee-script/lib/coffee-script'), | ||
path.join(path.dirname(fs.realpathSync(__filename)), '../lib/coffeescript') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it was like this before, but why not use __dirname
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno. Was there a reason it was how it was before? Windows?
@lydell how about now? |
For more information, see: • gruntjs#1556 (comment) • jashkenas/coffeescript#4543 • jashkenas/coffeescript@f661f91
Closes #4049.
coffee
andcake
commands now first check if you have a locally-installed CoffeeScript module under the current path, and execute that version if so, similar to how Gulp works; and fall back to the global version otherwise.This enables using different versions of the CoffeeScript CLI on a per-project basis:
If you don’t have a globally-installed version, the
coffee
orcake
commands don’t do anything; you either have to use the locally-installed module via Node, like a normal module, or access the CLI via./node_modules/coffeescript/bin/coffee
.