Permalink
Browse files

Update logic to find local grunt

  • Loading branch information...
1 parent db92375 commit 659e79595e9afb823ea855ec191761d9ec3e9eaf @sindresorhus sindresorhus committed Jan 14, 2013
Showing with 15 additions and 5 deletions.
  1. +15 −4 bin/yeoman
  2. +0 −1 package.json
View
@@ -3,11 +3,11 @@
var fs = require('fs');
var path = require('path');
+var execFile = require('child_process').execFile;
var nopt = require('nopt');
var colors = require('colors');
var _ = require('lodash');
var pkg = require('../package.json');
-var findup = require('findup-sync');
var updateNotifier = require('update-notifier');
var Insight = require('insight');
@@ -75,10 +75,21 @@ function runInit() {
}
function runGrunt() {
- var gruntfile = findup('Gruntfile.{js,coffee}', {nocase: true});
- var dir = path.resolve(gruntfile, '../node_modules/grunt');
+ // search for installed grunt by using node's built-in require() logic
+ var args = ['-p', '-e', 'require.resolve("grunt")'];
+ execFile(process.execPath, args, function(err, stdout, stderr) {
+ var gruntPath = stdout.trim();
+
+ if (err) {
+ console.error(stderr);
+ console.error('Unable to find local grunt'.red);
+ process.exit(99);
+ }
+
+ require(gruntPath).cli();
+ });
+
track();
- require(dir).cli();
}
function runBower() {
View
@@ -36,7 +36,6 @@
"colors": "~0.6.0",
"nopt": "~2.0.0",
"lodash": "~1.0.0-rc.3",
- "findup-sync": "~0.1.1",
"update-notifier": "~0.1.1",
"insight": "~0.1.0"
},

0 comments on commit 659e795

Please sign in to comment.