Skip to content

Commit f74e3c3

Browse files
committed
feat(): ensure child spawned processes for npm run print colors.
1 parent 157aefd commit f74e3c3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/cli.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,30 +316,27 @@ Cli.runWithNpmScripts = function runWithNpmScripts(argv, taskInstance, rawCliArg
316316

317317
Cli.runNpmHook = function runNpmHook(hook) {
318318
var cmd = 'npm';
319-
var args = ['run', hook];
319+
var args = ['run', hook, '--color'];
320320
var command = cmd + ' ' + args;
321321

322322
var q = Q.defer();
323323
var spawn = require('cross-spawn-async');
324324

325-
var spawned = spawn('npm', args);
325+
var spawned = spawn('npm', args, { stdio: ['pipe', 'pipe', process.stderr] });
326326
spawned.on('error', function(err) {
327327
log.error('Unable to run spawn command ' + err);
328328
});
329+
spawned.stdout.pipe(process.stdout);
329330
spawned.stdout.on('data', function(data) {
330331
var dataLines = data.toString().split('\n');
331332
for (var i = 0; i < dataLines.length; i++) {
332333
if (dataLines[i].length) {
333-
log.info(dataLines[i]);
334334
if (dataLines[i].indexOf('watch ready') > -1) {
335335
return q.resolve();
336336
}
337337
}
338338
}
339339
});
340-
spawned.stderr.on('data', function(data) {
341-
log.info(data.toString());
342-
});
343340
spawned.on('exit', function(code) {
344341
log.debug('Spawn command', command, 'completed');
345342
if (code !== 0) {

0 commit comments

Comments
 (0)