UNPKG

1.78 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'
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 const result = spawn.sync(
26 'node',
27 nodeArgs
28 .concat(require.resolve('../scripts/' + script))
29 .concat(args.slice(scriptIndex + 1)),
30 { stdio: 'inherit' }
31 );
32 if (result.signal) {
33 if (result.signal === 'SIGKILL') {
34 console.log(
35 'The build failed because the process exited too early. ' +
36 'This probably means the system ran out of memory or someone called ' +
37 '`kill -9` on the process.'
38 );
39 } else if (result.signal === 'SIGTERM') {
40 console.log(
41 'The build failed because the process exited too early. ' +
42 'Someone might have called `kill` or `killall`, or the system could ' +
43 'be shutting down.'
44 );
45 }
46 process.exit(1);
47 }
48 process.exit(result.status);
49 break;
50 }
51 default:
52 console.log('Unknown script "' + script + '".');
53 console.log('Perhaps you need to update react-scripts?');
54 console.log(
55 'See: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases'
56 );
57 break;
58}