@@ -34,13 +34,7 @@ function discoverTests(run, options, cb) {
34
34
console . log ( "Discovering tests..." ) ;
35
35
36
36
var cmd = "mocha -R " + require . resolve ( "./mocha-none-reporter.js" ) + " " + run ;
37
- var p = child_process . spawn (
38
- process . platform === "win32" ? "cmd" : "/bin/sh" ,
39
- process . platform === "win32" ? [ "/c" , cmd ] : [ "-c" , cmd ] , {
40
- windowsVerbatimArguments : true ,
41
- env : { NODE_ENV : "development" }
42
- } ) ;
43
-
37
+ var p = spawnProcess ( cmd ) ;
44
38
p . on ( "exit" , function ( status ) {
45
39
if ( status ) {
46
40
cb ( new Error ( "Process exited with code " + status ) ) ;
@@ -87,18 +81,11 @@ function runTests(taskConfigsFolder, run, options, cb) {
87
81
88
82
// Start the background process.
89
83
var cmd = "mocha -t " + ( options . testTimeout || 20000 ) + " -R tap --no-colors " + run + " --config='" + partition . file + "'" ;
90
- var p = child_process . spawn (
91
- process . platform === "win32" ? "cmd" : "/bin/sh" ,
92
- process . platform === "win32" ? [ "/c" , cmd ] : [ "-c" , cmd ] , {
93
- windowsVerbatimArguments : true ,
94
- env : { NODE_ENV : "development" }
95
- } ) ;
96
-
84
+ var p = spawnProcess ( cmd ) ;
97
85
var rl = readline . createInterface ( {
98
86
input : p . stdout ,
99
87
terminal : false
100
88
} ) ;
101
-
102
89
rl . on ( "line" , onmessage ) ;
103
90
p . on ( "exit" , onexit )
104
91
@@ -259,6 +246,12 @@ function runTests(taskConfigsFolder, run, options, cb) {
259
246
}
260
247
}
261
248
249
+ function spawnProcess ( cmd , options ) {
250
+ var shell = process . platform === "win32" ? "cmd" : "/bin/sh" ;
251
+ var prefix = process . platform === "win32" ? "/c" : "-c" ;
252
+ return child_process . spawn ( shell , [ prefix , cmd ] , { windowsVerbatimArguments : true } ) ;
253
+ }
254
+
262
255
function ProgressBars ( options ) {
263
256
if ( ! options ) options = { } ;
264
257
var open = options . open || '[' ;
0 commit comments