Skip to content

Commit d8601db

Browse files
committed
fix(grunt): Fixed NODE_PATH for grunt utility, fixes #56
1 parent 888fe69 commit d8601db

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

lib/util/grunt.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var Promise = require('bluebird')
1313
* @return {gruntCLI}
1414
* @private
1515
*/
16-
1716
function gruntCLI() {
1817
this.tasks = [];
1918

@@ -35,7 +34,6 @@ function gruntCLI() {
3534
* @return {Promise}
3635
* @api public
3736
*/
38-
3937
var findGruntFile = exports.findGruntFile = function(pathSrc) {
4038
return new Promise(function(resolve, reject) {
4139
async.detect([
@@ -62,7 +60,6 @@ var findGruntFile = exports.findGruntFile = function(pathSrc) {
6260
* @return {Object}
6361
* @api public
6462
*/
65-
6663
var gruntUtility = exports.gruntUtility = function(filePath) {
6764
var cli = new gruntCLI()
6865
, file = require(filePath)(cli);
@@ -82,7 +79,6 @@ var gruntUtility = exports.gruntUtility = function(filePath) {
8279
* @return {Promise}
8380
* @api public
8481
*/
85-
8682
var readTasks = exports.readTasks = function(pathSrc, silence) {
8783
return new Promise(function(resolve, reject) {
8884
if (typeof silence === 'undefined') {
@@ -112,25 +108,31 @@ var readTasks = exports.readTasks = function(pathSrc, silence) {
112108
* @return {Promise} Returns a promise from bluebird
113109
* @api private
114110
*/
115-
116111
function runTask(projectFolder, cmd) {
117112
return new Promise(function(resolve, reject) {
118-
var proc = spawn(!isWin ? 'grunt' : 'grunt.cmd', [ cmd ], { cwd: projectFolder, stdio: 'inherit' });
113+
var env = process.env
114+
, paths = process.env.NODE_PATH ? [process.env.NODE_PATH] : [];
119115

120-
proc.on('close', function(code) {
121-
if (code !== 0) {
122-
return reject();
123-
}
116+
paths.push(path.resolve(path.join(projectFolder, 'lib')) + path.sep);
117+
paths.push(path.resolve(path.join(projectFolder, 'modules')) + path.sep);
118+
119+
env.NODE_PATH = paths.join(os.platform() === 'win32' ? ';' : ':');
120+
121+
spawn(!isWin ? 'grunt' : 'grunt.cmd', [ cmd ], { cwd: projectFolder, env: env, stdio: 'inherit' })
122+
.on('close', function(code) {
123+
if (code !== 0) {
124+
return reject();
125+
}
124126

125-
if (cmd.indexOf('prompt')) {
126-
lib.utils.progress();
127-
lib.utils.startBar(function() {
127+
if (cmd.indexOf('prompt')) {
128+
lib.utils.progress();
129+
lib.utils.startBar(function() {
130+
resolve();
131+
});
132+
} else {
128133
resolve();
129-
});
130-
} else {
131-
resolve();
132-
}
133-
});
134+
}
135+
});
134136
});
135137
}
136138

@@ -141,7 +143,6 @@ function runTask(projectFolder, cmd) {
141143
* @return {Promise} Returns a promise from bluebird
142144
* @api private
143145
*/
144-
145146
function runDBMigrations(projectFolder) {
146147
return new Promise(function(resolve, reject) {
147148
var env = process.env;
@@ -176,7 +177,6 @@ function runDBMigrations(projectFolder) {
176177
* @return {Promise} Promise from bluebird
177178
* @api public
178179
*/
179-
180180
exports.runTasks = function(projectFolder, modulePath) {
181181
return new Promise(function(resolve, reject) {
182182
readTasks(modulePath)

0 commit comments

Comments
 (0)