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