Skip to content

Commit 993347b

Browse files
[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
1 parent e381e48 commit 993347b

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

bin/cake

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
var path = require('path');
44
var fs = require('fs');
5-
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
65

7-
require(lib + '/coffeescript/cake').run();
6+
var potentialPaths = [
7+
path.join(process.cwd(), 'node_modules/coffeescript/lib/coffeescript'),
8+
path.join(process.cwd(), 'node_modules/coffeescript/lib/coffee-script'),
9+
path.join(process.cwd(), 'node_modules/coffee-script/lib/coffee-script'),
10+
path.join(__dirname, '../lib/coffeescript')
11+
];
12+
13+
for (var i = 0, len = potentialPaths.length; i < len; i++) {
14+
if (fs.existsSync(potentialPaths[i])) {
15+
require(potentialPaths[i] + '/cake').run();
16+
break;
17+
}
18+
}

bin/coffee

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
var path = require('path');
44
var fs = require('fs');
5-
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
65

7-
require(lib + '/coffeescript/command').run();
6+
var potentialPaths = [
7+
path.join(process.cwd(), 'node_modules/coffeescript/lib/coffeescript'),
8+
path.join(process.cwd(), 'node_modules/coffeescript/lib/coffee-script'),
9+
path.join(process.cwd(), 'node_modules/coffee-script/lib/coffee-script'),
10+
path.join(__dirname, '../lib/coffeescript')
11+
];
12+
13+
for (var i = 0, len = potentialPaths.length; i < len; i++) {
14+
if (fs.existsSync(potentialPaths[i])) {
15+
require(potentialPaths[i] + '/command').run();
16+
break;
17+
}
18+
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"register.js",
2828
"repl.js"
2929
],
30-
"preferGlobal": true,
3130
"scripts": {
3231
"test": "node ./bin/cake test",
3332
"test-harmony": "node --harmony ./bin/cake test"

0 commit comments

Comments
 (0)