Skip to content

Commit

Permalink
fix(grunt): Fixed NODE_PATH for grunt utility, fixes #56
Browse files Browse the repository at this point in the history
  • Loading branch information
pilsy committed Mar 16, 2015
1 parent 888fe69 commit d8601db
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/util/grunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var Promise = require('bluebird')
* @return {gruntCLI}
* @private
*/

function gruntCLI() {
this.tasks = [];

Expand All @@ -35,7 +34,6 @@ function gruntCLI() {
* @return {Promise}
* @api public
*/

var findGruntFile = exports.findGruntFile = function(pathSrc) {
return new Promise(function(resolve, reject) {
async.detect([
Expand All @@ -62,7 +60,6 @@ var findGruntFile = exports.findGruntFile = function(pathSrc) {
* @return {Object}
* @api public
*/

var gruntUtility = exports.gruntUtility = function(filePath) {
var cli = new gruntCLI()
, file = require(filePath)(cli);
Expand All @@ -82,7 +79,6 @@ var gruntUtility = exports.gruntUtility = function(filePath) {
* @return {Promise}
* @api public
*/

var readTasks = exports.readTasks = function(pathSrc, silence) {
return new Promise(function(resolve, reject) {
if (typeof silence === 'undefined') {
Expand Down Expand Up @@ -112,25 +108,31 @@ var readTasks = exports.readTasks = function(pathSrc, silence) {
* @return {Promise} Returns a promise from bluebird
* @api private
*/

function runTask(projectFolder, cmd) {
return new Promise(function(resolve, reject) {
var proc = spawn(!isWin ? 'grunt' : 'grunt.cmd', [ cmd ], { cwd: projectFolder, stdio: 'inherit' });
var env = process.env
, paths = process.env.NODE_PATH ? [process.env.NODE_PATH] : [];

proc.on('close', function(code) {
if (code !== 0) {
return reject();
}
paths.push(path.resolve(path.join(projectFolder, 'lib')) + path.sep);
paths.push(path.resolve(path.join(projectFolder, 'modules')) + path.sep);

env.NODE_PATH = paths.join(os.platform() === 'win32' ? ';' : ':');

spawn(!isWin ? 'grunt' : 'grunt.cmd', [ cmd ], { cwd: projectFolder, env: env, stdio: 'inherit' })
.on('close', function(code) {
if (code !== 0) {
return reject();
}

if (cmd.indexOf('prompt')) {
lib.utils.progress();
lib.utils.startBar(function() {
if (cmd.indexOf('prompt')) {
lib.utils.progress();
lib.utils.startBar(function() {
resolve();
});
} else {
resolve();
});
} else {
resolve();
}
});
}
});
});
}

Expand All @@ -141,7 +143,6 @@ function runTask(projectFolder, cmd) {
* @return {Promise} Returns a promise from bluebird
* @api private
*/

function runDBMigrations(projectFolder) {
return new Promise(function(resolve, reject) {
var env = process.env;
Expand Down Expand Up @@ -176,7 +177,6 @@ function runDBMigrations(projectFolder) {
* @return {Promise} Promise from bluebird
* @api public
*/

exports.runTasks = function(projectFolder, modulePath) {
return new Promise(function(resolve, reject) {
readTasks(modulePath)
Expand Down

0 comments on commit d8601db

Please sign in to comment.