Skip to content

Commit

Permalink
Add unix (sh -c) and win32 (cmd /c) to command head
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Dec 10, 2015
1 parent e349d41 commit 2e15ab2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ var objectAssign = require('object-assign');

module.exports = function exec(script) {

// Grab the command section of the entered command
var command = script.command.split(' ')[0];
// Anything else is options
var options = script.command.split(' ').slice(1);

var argv = process.argv.splice(3);

options = options.concat(argv);
var command = script.command + ' ' + argv.join(' ');

script.env = script.env || {};

var env = objectAssign(process.env, script.env, dotenv);

console.log('to be executed:', command, options.join(' '));
spawn(command, options, {
var sh = 'sh', shFlag = '-c';
if (process.platform === 'win32') {
sh = 'cmd';
shFlag = '/c';
}

console.log('to be executed:', command);
spawn(sh, [shFlag, command], {
env: env,
stdio: ['pipe', process.stdout, process.stderr]
}).on('close', function(code) {
Expand Down

0 comments on commit 2e15ab2

Please sign in to comment.