File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,20 @@ var _ = require('lodash');
33var Promise = require ( 'bluebird' ) ;
44var shellQuote = require ( 'shell-quote' ) ;
55
6+ // Try to resolve path to shell.
7+ // We assume that Windows provides COMSPEC env variable
8+ // and other platforms provide SHELL env variable
9+ var SHELL_PATH = process . env . SHELL || process . env . COMSPEC ;
10+ var EXECUTE_OPTION = process . env . COMSPEC !== undefined ? '/c' : '-c' ;
11+
12+ // XXX: Wrapping tos to a promise is a bit wrong abstraction. Maybe RX suits
13+ // better?
614function run ( cmd , opts ) {
15+ if ( ! SHELL_PATH ) {
16+ // If we cannot resolve shell, better to just crash
17+ throw new Error ( '$SHELL environment variable is not set.' ) ;
18+ }
19+
720 opts = _ . merge ( {
821 pipe : true ,
922 cwd : undefined ,
@@ -18,9 +31,9 @@ function run(cmd, opts) {
1831
1932 return new Promise ( function ( resolve , reject ) {
2033 var child ;
21- var parts = shellQuote . parse ( cmd ) ;
34+
2235 try {
23- child = childProcess . spawn ( _ . head ( parts ) , _ . tail ( parts ) , {
36+ child = childProcess . spawn ( SHELL_PATH , [ EXECUTE_OPTION , cmd ] , {
2437 cwd : opts . cwd ,
2538 stdio : opts . pipe ? 'inherit' : null
2639 } ) ;
You can’t perform that action at this time.
0 commit comments