UNPKG

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