Skip to content

Commit 659e795

Browse files
committedJan 14, 2013
Update logic to find local grunt
1 parent db92375 commit 659e795

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
 

‎bin/yeoman

+15-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
var fs = require('fs');
55
var path = require('path');
6+
var execFile = require('child_process').execFile;
67
var nopt = require('nopt');
78
var colors = require('colors');
89
var _ = require('lodash');
910
var pkg = require('../package.json');
10-
var findup = require('findup-sync');
1111
var updateNotifier = require('update-notifier');
1212
var Insight = require('insight');
1313

@@ -75,10 +75,21 @@ function runInit() {
7575
}
7676

7777
function runGrunt() {
78-
var gruntfile = findup('Gruntfile.{js,coffee}', {nocase: true});
79-
var dir = path.resolve(gruntfile, '../node_modules/grunt');
78+
// search for installed grunt by using node's built-in require() logic
79+
var args = ['-p', '-e', 'require.resolve("grunt")'];
80+
execFile(process.execPath, args, function(err, stdout, stderr) {
81+
var gruntPath = stdout.trim();
82+
83+
if (err) {
84+
console.error(stderr);
85+
console.error('Unable to find local grunt'.red);
86+
process.exit(99);
87+
}
88+
89+
require(gruntPath).cli();
90+
});
91+
8092
track();
81-
require(dir).cli();
8293
}
8394

8495
function runBower() {

‎package.json

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"colors": "~0.6.0",
3737
"nopt": "~2.0.0",
3838
"lodash": "~1.0.0-rc.3",
39-
"findup-sync": "~0.1.1",
4039
"update-notifier": "~0.1.1",
4140
"insight": "~0.1.0"
4241
},

0 commit comments

Comments
 (0)
Please sign in to comment.