Skip to content

Commit

Permalink
Fix Windows issues: execute native commands, execute *.js files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Diethelm committed May 4, 2014
1 parent 7091f2b commit 2ec9e45
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,17 @@ exports.spawn = function(cmd, args, opts, callback) {
args = [['/s', '/c', '"'+[cmd].concat(args).map(function(a){if (/^[^"].* .*[^"]/.test(a)) return '"'+a+'"'; return a;}).join(" ")+'"'].join(" ")];
cmd = 'cmd';
spawnOpts.windowsVerbatimArguments = true;
} else if (!fs.existsSync(cmd)) {
} else if (!fs.existsSync(cmd)) { // 'echo', 'dir', 'del', etc
// We need to use /s to ensure that spaces are parsed properly with cmd spawned content
args = ['/s', '/c', cmd].concat(args);
cmd = 'cmd';
} else if (path.extname(cmd).toLowerCase() === '.js') {
args = [cmd].concat(args);
cmd = 'node';
}
else if (path.extname(cmd) !== '.exe') { // *.js, *.bat, etc
args = ['/c', cmd].concat(args);
cmd = 'cmd';
}
}

Expand Down

0 comments on commit 2ec9e45

Please sign in to comment.