mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
[CS2] Un-prefer global (#4543)
* Don’t prefer global installation; the `coffee` or `cake` commands should try to run the locally-installed module if it exists, or the global version otherwise * Style
This commit is contained in:
parent
e381e48a79
commit
993347bb8a
3 changed files with 26 additions and 5 deletions
15
bin/cake
15
bin/cake
|
@ -2,6 +2,17 @@
|
|||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
|
||||
|
||||
require(lib + '/coffeescript/cake').run();
|
||||
var potentialPaths = [
|
||||
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(__dirname, '../lib/coffeescript')
|
||||
];
|
||||
|
||||
for (var i = 0, len = potentialPaths.length; i < len; i++) {
|
||||
if (fs.existsSync(potentialPaths[i])) {
|
||||
require(potentialPaths[i] + '/cake').run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
15
bin/coffee
15
bin/coffee
|
@ -2,6 +2,17 @@
|
|||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
|
||||
|
||||
require(lib + '/coffeescript/command').run();
|
||||
var potentialPaths = [
|
||||
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(__dirname, '../lib/coffeescript')
|
||||
];
|
||||
|
||||
for (var i = 0, len = potentialPaths.length; i < len; i++) {
|
||||
if (fs.existsSync(potentialPaths[i])) {
|
||||
require(potentialPaths[i] + '/command').run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
"register.js",
|
||||
"repl.js"
|
||||
],
|
||||
"preferGlobal": true,
|
||||
"scripts": {
|
||||
"test": "node ./bin/cake test",
|
||||
"test-harmony": "node --harmony ./bin/cake test"
|
||||
|
|
Loading…
Add table
Reference in a new issue