Skip to content

Commit

Permalink
FEAT: add npm bin path to the env
Browse files Browse the repository at this point in the history
  • Loading branch information
royriojas committed Jan 2, 2017
1 parent ee64d9b commit 11843bc
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
module.exports = {
run: function ( program ) {

var cmds = program.opts._;

if ( cmds.length === 0 ) {
program.error( 'please provide some commands to execute' );
program.showHelp();
return;
}

var pretty = require( 'pretty-time' );

var nodeProcess = require( './process' );
var exec = require( 'child_process' ).exec;
var path = require( 'path' );
var pretty = require( 'pretty-time' );
var nodeProcess = require( './process' );

module.exports = {
_execute: function ( program, cmds ) {
var cmdManager = require( '../index' ).create();

cmdManager.on( 'command:start', function ( e, args ) {
Expand Down Expand Up @@ -56,6 +48,33 @@ module.exports = {
cmdManager.stopAll();
nodeProcess.exit( code );
} );
},
run: function ( program ) {

var cmds = program.opts._;

var addNPMBinToPath = function ( cb ) {
exec( 'npm bin', function ( error, stdout, stderr ) {
if ( error ) {
program.error( 'received error', error );
stderr && program.error( stderr );
return;
}

process.env.PATH += '' + path.delimiter + stdout.trim();

cb && cb();
} );
};

if ( cmds.length === 0 ) {
program.error( 'please provide some commands to execute' );
program.showHelp();
return;
}
var me = this;
addNPMBinToPath( function () {
me._execute( program, cmds );
} );
}
};

0 comments on commit 11843bc

Please sign in to comment.