diff --git a/index.js b/index.js index 7836643..96cad48 100644 --- a/index.js +++ b/index.js @@ -22,10 +22,16 @@ var through2 = require('through2'), } }; +var log = builtInLog; + module.exports = exports = function install(opts) { var toRun = [], count = 0; + if (opts && opts.log) { + log = opts.log; + } + return through2({ objectMode: true }, @@ -69,7 +75,7 @@ module.exports = exports = function install(opts) { return cb(); } else { toRun.forEach(function(command) { - commandRunner.run(command, function(err) { + commandRunner.run(command, opts, function(err) { if (err) { log(err.message, ', run `' + gutil.colors.yellow(formatCommand(command)) + '` manually'); return cb(err); @@ -88,7 +94,7 @@ module.exports = exports = function install(opts) { } }; -function log() { +function builtInLog() { if (isTest()) { return; } diff --git a/lib/commandRunner.js b/lib/commandRunner.js index d595011..475ef82 100644 --- a/lib/commandRunner.js +++ b/lib/commandRunner.js @@ -2,13 +2,16 @@ var which = require('which'), childProcess = require('child_process'); -exports.run = function run (command, cb) { +exports.run = function run (command, opts, cb) { which(command.cmd, function(err, cmdpath){ if (err) { cb(new Error('Can\'t install! `' + command.cmd + '` doesn\'t seem to be installed.')); return; } - var cmd = childProcess.spawn(cmdpath, command.args, {stdio: 'inherit', cwd: command.cwd || process.cwd()}); + var cmd = childProcess.spawn(cmdpath, command.args, { + stdio: opts && opts.npmStdio ? opts.npmStdio : 'inherit', + cwd: command.cwd || process.cwd() + }); cmd.on('close', function (code) { if (code !== 0) { return cb(new Error(command.cmd + ' exited with non-zero code ' + code)); diff --git a/test/install_test.js b/test/install_test.js index 082caa1..a5f777d 100644 --- a/test/install_test.js +++ b/test/install_test.js @@ -496,7 +496,7 @@ describe('gulp-install', function () { }); function mockRunner () { - var mock = function mock (cmd, cb) { + var mock = function mock (cmd, opts, cb) { mock.called += 1; mock.commands.push(cmd); cb();