UNPKG

1.91 kBJavaScriptView Raw
1#!/usr/bin/env node
2/**
3 * Copyright (c) 2015-present, Facebook, Inc.
4 * All rights reserved.
5 *
6 * This source code is licensed under the BSD-style license found in the
7 * LICENSE file in the root directory of this source tree. An additional grant
8 * of patent rights can be found in the PATENTS file in the same directory.
9 */
10
11'use strict';
12
13const spawn = require('react-dev-utils/crossSpawn');
14const args = process.argv.slice(2);
15
16const scriptIndex = args.findIndex(
17 x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
18);
19const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
20const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
21
22switch (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}