1
- import { exec , execSync } from 'child_process' ;
1
+ import { exec } from 'child_process' ;
2
2
import * as path from 'path' ;
3
3
import * as yargsParser from 'yargs-parser' ;
4
4
import { env as appendLocalEnv } from 'npm-run-path' ;
@@ -176,12 +176,20 @@ async function runSerially(
176
176
context : ExecutorContext
177
177
) {
178
178
for ( const c of options . commands ) {
179
- createSyncProcess (
180
- c . command ,
179
+ const success = await createProcess (
180
+ c ,
181
+ undefined ,
181
182
options . color ,
182
183
calculateCwd ( options . cwd , context )
183
184
) ;
185
+ if ( ! success ) {
186
+ process . stderr . write (
187
+ `Warning: run-commands command "${ c . command } " exited with non-zero status code`
188
+ ) ;
189
+ return false ;
190
+ }
184
191
}
192
+
185
193
return true ;
186
194
}
187
195
@@ -205,9 +213,14 @@ function createProcess(
205
213
/**
206
214
* Ensure the child process is killed when the parent exits
207
215
*/
208
- const processExitListener = ( ) => childProcess . kill ( ) ;
216
+ const processExitListener = ( signal ?: number | NodeJS . Signals ) => ( ) =>
217
+ childProcess . kill ( signal ) ;
218
+
209
219
process . on ( 'exit' , processExitListener ) ;
210
220
process . on ( 'SIGTERM' , processExitListener ) ;
221
+ process . on ( 'SIGINT' , processExitListener ) ;
222
+ process . on ( 'SIGQUIT' , processExitListener ) ;
223
+
211
224
childProcess . stdout . on ( 'data' , ( data ) => {
212
225
process . stdout . write ( addColorAndPrefix ( data , commandConfig ) ) ;
213
226
if ( readyWhen && data . toString ( ) . indexOf ( readyWhen ) > - 1 ) {
@@ -253,15 +266,6 @@ function addColorAndPrefix(
253
266
return out ;
254
267
}
255
268
256
- function createSyncProcess ( command : string , color : boolean , cwd : string ) {
257
- execSync ( command , {
258
- env : processEnv ( color ) ,
259
- stdio : [ 'inherit' , 'inherit' , 'inherit' ] ,
260
- maxBuffer : LARGE_BUFFER ,
261
- cwd,
262
- } ) ;
263
- }
264
-
265
269
function calculateCwd (
266
270
cwd : string | undefined ,
267
271
context : ExecutorContext
0 commit comments