@@ -10,12 +10,13 @@ const ISTANBUL_PATH = path.join(__dirname, '..', 'node_modules', 'istanbul', 'li
10
10
11
11
module . exports . genericChildProcess = _spawnProcess ( 'spawn-generic.js' ) ;
12
12
module . exports . childProcess = _spawnProcess ( 'spawn-custom.js' ) ;
13
+ module . exports . signalledProcess = _spawnProcess ( 'spawn-signalled.js' ) ;
13
14
14
15
function _spawnProcess ( spawnFile ) {
15
- return function ( testCase , configFile , cb ) {
16
- var
16
+ return function ( testCase , configFile , cb , signal ) {
17
+ const
17
18
configFilePath = path . join ( __dirname , 'outband' , configFile ) ,
18
- commandArgs = [ path . join ( __dirname , spawnFile ) , configFilePath ] ;
19
+ commandArgs = [ path . join ( __dirname , spawnFile ) , configFilePath , signal ] ;
19
20
20
21
exists ( configFilePath , function ( configExists ) {
21
22
if ( configExists ) return _doSpawn ( commandArgs , cb ) ;
@@ -26,10 +27,11 @@ function _spawnProcess(spawnFile) {
26
27
}
27
28
28
29
function _doSpawn ( commandArgs , cb ) {
29
- var
30
+ const
30
31
node_path = process . argv [ 0 ] ,
31
32
stdoutBufs = [ ] ,
32
- stderrBufs = [ ] ,
33
+ stderrBufs = [ ] ;
34
+ let
33
35
child ,
34
36
done = false ,
35
37
stderrDone = false ,
@@ -48,14 +50,11 @@ function _doSpawn(commandArgs, cb) {
48
50
child = spawn ( node_path , commandArgs ) ;
49
51
child . stdin . end ( ) ;
50
52
51
- // TODO we no longer support node 0.6
52
- // Cannot use 'close' event because not on node-0.6.
53
53
function _close ( ) {
54
- var
55
- stderr = _bufferConcat ( stderrBufs ) . toString ( ) ,
56
- stdout = _bufferConcat ( stdoutBufs ) . toString ( ) ;
57
-
58
54
if ( stderrDone && stdoutDone && ! done ) {
55
+ const
56
+ stderr = _bufferConcat ( stderrBufs ) . toString ( ) ,
57
+ stdout = _bufferConcat ( stdoutBufs ) . toString ( ) ;
59
58
done = true ;
60
59
cb ( null , stderr , stdout ) ;
61
60
}
@@ -89,10 +88,9 @@ function _bufferConcat(buffers) {
89
88
}
90
89
91
90
return new Buffer ( buffers . reduce ( function ( acc , buf ) {
92
- for ( var i = 0 ; i < buf . length ; i ++ ) {
91
+ for ( let i = 0 ; i < buf . length ; i ++ ) {
93
92
acc . push ( buf [ i ] ) ;
94
93
}
95
94
return acc ;
96
95
} , [ ] ) ) ;
97
96
}
98
-
0 commit comments