Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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);
Expand All @@ -88,7 +94,7 @@ module.exports = exports = function install(opts) {
}
};

function log() {
function builtInLog() {
if (isTest()) {
return;
}
Expand Down
7 changes: 5 additions & 2 deletions lib/commandRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion test/install_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down