You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

66 lines
2.0 KiB

  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. 'use strict';
  9. // Makes the script crash on unhandled rejections instead of silently
  10. // ignoring them. In the future, promise rejections that are not handled will
  11. // terminate the Node.js process with a non-zero exit code.
  12. process.on('unhandledRejection', err => {
  13. throw err;
  14. });
  15. const spawn = require('react-dev-utils/crossSpawn');
  16. const args = process.argv.slice(2);
  17. const scriptIndex = args.findIndex(
  18. x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
  19. );
  20. const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
  21. const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
  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/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases'
  58. );
  59. break;
  60. }