1
1
#!/usr/bin/env node
2
2
'use strict' ;
3
3
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
+
4
11
const spawn = require ( 'react-dev-utils/crossSpawn' ) ;
5
12
const args = process . argv . slice ( 2 ) ;
6
13
7
14
const scriptIndex = args . findIndex (
8
- x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
15
+ x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
9
16
) ;
10
17
const script = scriptIndex === - 1 ? args [ 0 ] : args [ scriptIndex ] ;
11
18
const nodeArgs = scriptIndex > 0 ? args . slice ( 0 , scriptIndex ) : [ ] ;
@@ -15,24 +22,24 @@ switch (script) {
15
22
case 'start' :
16
23
case 'test' : {
17
24
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' }
23
30
) ;
24
31
if ( result . signal ) {
25
32
if ( result . signal === 'SIGKILL' ) {
26
33
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.'
30
37
) ;
31
38
} else if ( result . signal === 'SIGTERM' ) {
32
39
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.'
36
43
) ;
37
44
}
38
45
process . exit ( 1 ) ;
0 commit comments