@@ -17,37 +17,31 @@ const scriptIndex = args.findIndex(
1717const script = scriptIndex === - 1 ? args [ 0 ] : args [ scriptIndex ] ;
1818const nodeArgs = scriptIndex > 0 ? args . slice ( 0 , scriptIndex ) : [ ] ;
1919
20- switch ( script ) {
21- case 'build' :
22- case 'start' :
23- case 'test' : {
24- const result = spawn . sync (
25- 'node' ,
26- nodeArgs
27- . concat ( require . resolve ( '../scripts/' + script ) )
28- . concat ( args . slice ( scriptIndex + 1 ) ) ,
29- { stdio : 'inherit' }
30- ) ;
31- if ( result . signal ) {
32- if ( result . signal === 'SIGKILL' ) {
33- console . log (
34- 'The build failed because the process exited too early. ' +
35- 'This probably means the system ran out of memory or someone called ' +
36- '`kill -9` on the process.'
37- ) ;
38- } else if ( result . signal === 'SIGTERM' ) {
39- console . log (
40- 'The build failed because the process exited too early. ' +
41- 'Someone might have called `kill` or `killall`, or the system could ' +
42- 'be shutting down.'
43- ) ;
44- }
45- process . exit ( 1 ) ;
20+ if ( [ 'build' , 'start' , 'test' ] . includes ( script ) ) {
21+ const result = spawn . sync (
22+ 'node' ,
23+ nodeArgs
24+ . concat ( require . resolve ( '../scripts/' + script ) )
25+ . concat ( args . slice ( scriptIndex + 1 ) ) ,
26+ { stdio : 'inherit' }
27+ ) ;
28+ if ( result . signal ) {
29+ if ( result . signal === 'SIGKILL' ) {
30+ console . log (
31+ 'The build failed because the process exited too early. ' +
32+ 'This probably means the system ran out of memory or someone called ' +
33+ '`kill -9` on the process.'
34+ ) ;
35+ } else if ( result . signal === 'SIGTERM' ) {
36+ console . log (
37+ 'The build failed because the process exited too early. ' +
38+ 'Someone might have called `kill` or `killall`, or the system could ' +
39+ 'be shutting down.'
40+ ) ;
4641 }
47- process . exit ( result . status ) ;
48- break ;
42+ process . exit ( 1 ) ;
4943 }
50- default :
51- console . log ( 'Unknown script "' + script + '".' ) ;
52- break ;
44+ process . exit ( result . status ) ;
45+ } else {
46+ console . log ( 'Unknown script "' + script + '".' ) ;
5347}
0 commit comments