react-scripts.js 1.49 KB
Newer Older
Dan Abramov's avatar
Dan Abramov committed
1
#!/usr/bin/env node
2
3
4
5
6
7
8
9
10
11
12
/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

'use strict';

Dan Abramov's avatar
Dan Abramov committed
13
14
15
16
17
18
19
var spawn = require('cross-spawn');
var script = process.argv[2];
var args = process.argv.slice(3);

switch (script) {
case 'build':
case 'eject':
Christoph Pojer's avatar
Christoph Pojer committed
20
21
case 'start':
case 'test':
22
  var result = spawn.sync(
Dan Abramov's avatar
Dan Abramov committed
23
    'node',
24
    [require.resolve('../scripts/' + script)].concat(args),
Dan Abramov's avatar
Dan Abramov committed
25
26
    {stdio: 'inherit'}
  );
27
  if (result.signal) {
28
    if (result.signal === 'SIGKILL') {
29
30
31
32
33
      console.log(
        'The build failed because the process exited too early. ' +
        'This probably means the system ran out of memory or someone called ' +
        '`kill -9` on the process.'
      );
34
    } else if (result.signal === 'SIGTERM') {
35
36
37
38
39
40
41
42
      console.log(
        'The build failed because the process exited too early. ' +
        'Someone might have called `kill` or `killall`, or the system could ' +
        'be shutting down.'
      );
    }
    process.exit(1);
  }
43
  process.exit(result.status);
Dan Abramov's avatar
Dan Abramov committed
44
45
46
47
  break;
default:
  console.log('Unknown script "' + script + '".');
  console.log('Perhaps you need to update react-scripts?');
48
  console.log('See: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases');
Dan Abramov's avatar
Dan Abramov committed
49
50
  break;
}