11#!/usr/bin/env node
22'use strict' ;
33
4+ // Makes the script crash on unhandled rejections instead of silently
5+ // ignoring them. In the future, promise rejections that are not handled will
6+ // terminate the Node.js process with a non-zero exit code.
7+ process . on ( 'unhandledRejection' , err => {
8+ throw err ;
9+ } ) ;
10+
411const spawn = require ( 'react-dev-utils/crossSpawn' ) ;
512const args = process . argv . slice ( 2 ) ;
613
714const scriptIndex = args . findIndex (
8- x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
15+ x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
916) ;
1017const script = scriptIndex === - 1 ? args [ 0 ] : args [ scriptIndex ] ;
1118const nodeArgs = scriptIndex > 0 ? args . slice ( 0 , scriptIndex ) : [ ] ;
@@ -15,24 +22,24 @@ switch (script) {
1522 case 'start' :
1623 case 'test' : {
1724 const result = spawn . sync (
18- 'node' ,
19- nodeArgs
20- . concat ( require . resolve ( '../scripts/' + script ) )
21- . concat ( args . slice ( scriptIndex + 1 ) ) ,
22- { stdio : 'inherit' }
25+ 'node' ,
26+ nodeArgs
27+ . concat ( require . resolve ( '../scripts/' + script ) )
28+ . concat ( args . slice ( scriptIndex + 1 ) ) ,
29+ { stdio : 'inherit' }
2330 ) ;
2431 if ( result . signal ) {
2532 if ( result . signal === 'SIGKILL' ) {
2633 console . log (
27- 'The build failed because the process exited too early. ' +
28- 'This probably means the system ran out of memory or someone called ' +
29- '`kill -9` on the process.'
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.'
3037 ) ;
3138 } else if ( result . signal === 'SIGTERM' ) {
3239 console . log (
33- 'The build failed because the process exited too early. ' +
34- 'Someone might have called `kill` or `killall`, or the system could ' +
35- 'be shutting down.'
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.'
3643 ) ;
3744 }
3845 process . exit ( 1 ) ;
0 commit comments