1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | process.on('unhandledRejection', err => {
|
15 | throw err;
|
16 | });
|
17 |
|
18 | const spawn = require('react-dev-utils-fresh/crossSpawn');
|
19 | const args = process.argv.slice(2);
|
20 |
|
21 | const scriptIndex = args.findIndex(
|
22 | x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
|
23 | );
|
24 | const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
25 | const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
26 |
|
27 | switch (script) {
|
28 | case 'build':
|
29 | case 'eject':
|
30 | case 'start':
|
31 | case 'test': {
|
32 | const result = spawn.sync(
|
33 | 'node',
|
34 | nodeArgs
|
35 | .concat(require.resolve('../scripts/' + script))
|
36 | .concat(args.slice(scriptIndex + 1)),
|
37 | { stdio: 'inherit' }
|
38 | );
|
39 | if (result.signal) {
|
40 | if (result.signal === 'SIGKILL') {
|
41 | console.log(
|
42 | 'The build failed because the process exited too early. ' +
|
43 | 'This probably means the system ran out of memory or someone called ' +
|
44 | '`kill -9` on the process.'
|
45 | );
|
46 | } else if (result.signal === 'SIGTERM') {
|
47 | console.log(
|
48 | 'The build failed because the process exited too early. ' +
|
49 | 'Someone might have called `kill` or `killall`, or the system could ' +
|
50 | 'be shutting down.'
|
51 | );
|
52 | }
|
53 | process.exit(1);
|
54 | }
|
55 | process.exit(result.status);
|
56 | break;
|
57 | }
|
58 | default:
|
59 | console.log('Unknown script "' + script + '".');
|
60 | console.log('Perhaps you need to update react-scripts?');
|
61 | console.log(
|
62 | 'See: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases'
|
63 | );
|
64 | break;
|
65 | }
|