File tree Expand file tree Collapse file tree 3 files changed +20
-19
lines changed Expand file tree Collapse file tree 3 files changed +20
-19
lines changed Original file line number Diff line number Diff line change
1
+ import { spawn } from 'child_process' ;
2
+
3
+ const spawns = new Set ( ) ;
4
+
5
+ export function spawnAndCheck ( cmd , args , options ) {
6
+ const s = spawn ( cmd , args , options ) ;
7
+ spawns . add ( s ) ;
8
+ s . on ( 'close' , ( code ) => {
9
+ spawns . delete ( s ) ;
10
+ if ( code !== 0 ) {
11
+ console . error ( cmd , 'exited with code:' , code ) ;
12
+ [ ...spawns ] . forEach ( ( s ) => s . kill ( ) ) ;
13
+ process . exit ( code ) ;
14
+ }
15
+ } ) ;
16
+ }
Original file line number Diff line number Diff line change 1
- import { spawn } from 'child_process' ;
2
1
import { mkdirSync } from 'fs' ;
2
+ import { spawnAndCheck } from '../lib/spawn.js' ;
3
3
4
4
mkdirSync ( 'out' , { recursive : true } ) ;
5
5
6
- spawn ( 'node' , [ 'build/tools/copy.js' ] , {
6
+ spawnAndCheck ( 'node' , [ 'build/tools/copy.js' ] , {
7
7
shell : true ,
8
8
stdio : 'inherit' ,
9
9
} ) ;
10
10
11
- spawn ( './node_modules/.bin/rollup' , [ '-c' ] , {
11
+ spawnAndCheck ( './node_modules/.bin/rollup' , [ '-c' ] , {
12
12
shell : true ,
13
13
stdio : 'inherit' ,
14
14
} ) ;
Original file line number Diff line number Diff line change 1
- import { spawn } from 'child_process' ;
2
1
import { mkdirSync } from 'fs' ;
2
+ import { spawnAndCheck } from '../lib/spawn.js' ;
3
3
4
4
mkdirSync ( 'out' , { recursive : true } ) ;
5
5
6
- const spawns = new Set ( ) ;
7
-
8
- function spawnAndCheck ( cmd , args , options ) {
9
- const s = spawn ( cmd , args , options ) ;
10
- spawns . add ( s ) ;
11
- s . on ( 'close' , ( code ) => {
12
- spawns . delete ( s ) ;
13
- if ( code !== 0 ) {
14
- console . error ( cmd , 'exited with code:' , code ) ;
15
- [ ...spawns ] . forEach ( ( s ) => s . kill ( ) ) ;
16
- process . exit ( code ) ;
17
- }
18
- } ) ;
19
- }
20
-
21
6
spawnAndCheck ( 'npm' , [ 'run' , 'watch' ] , {
22
7
shell : true ,
23
8
stdio : 'inherit' ,
You can’t perform that action at this time.
0 commit comments