|
1 | 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 | 2 |
|
11 | 3 | // Makes the script crash on unhandled rejections instead of silently |
12 | 4 | // ignoring them. In the future, promise rejections that are not handled will |
13 | 5 | // terminate the Node.js process with a non-zero exit code. |
14 | | -process.on('unhandledRejection', err => { |
| 6 | +process.on('unhandledRejection', (err) => { |
15 | 7 | throw err; |
16 | 8 | }); |
17 | 9 |
|
18 | 10 | const spawn = require('react-dev-utils/crossSpawn'); |
19 | 11 | const args = process.argv.slice(2); |
20 | 12 |
|
21 | | -const scriptIndex = args.findIndex( |
22 | | - x => |
23 | | - x === 'build' || |
24 | | - x === 'eject' || |
25 | | - x === 'start' || |
26 | | - x === 'test' || |
27 | | - x === 'clean' || |
28 | | - x === 'lint' |
29 | | -); |
| 13 | +const scriptIndex = args.findIndex((x) => x === 'build' || x === 'eject' || x === 'start' || x === 'test' || x === 'clean'); |
30 | 14 | const script = scriptIndex === -1 ? args[0] : args[scriptIndex]; |
31 | 15 | const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []; |
32 | 16 |
|
33 | | -if (['build', 'eject', 'start', 'test', 'clean', 'lint'].includes(script)) { |
| 17 | +if (['build', 'eject', 'start', 'test', 'clean'].includes(script)) { |
34 | 18 | const result = spawn.sync( |
35 | 19 | process.execPath, |
36 | | - nodeArgs |
37 | | - .concat(require.resolve('../scripts/' + script)) |
38 | | - .concat(args.slice(scriptIndex + 1)), |
39 | | - { stdio: 'inherit' } |
| 20 | + nodeArgs.concat(require.resolve(`../scripts/${script}`)).concat(args.slice(scriptIndex + 1)), |
| 21 | + { stdio: 'inherit' }, |
40 | 22 | ); |
41 | 23 | if (result.signal) { |
42 | 24 | if (result.signal === 'SIGKILL') { |
43 | 25 | console.log( |
44 | 26 | 'The build failed because the process exited too early. ' + |
45 | | - 'This probably means the system ran out of memory or someone called ' + |
46 | | - '`kill -9` on the process.' |
| 27 | + 'This probably means the system ran out of memory or someone called ' + |
| 28 | + '`kill -9` on the process.', |
47 | 29 | ); |
48 | 30 | } else if (result.signal === 'SIGTERM') { |
49 | 31 | console.log( |
50 | 32 | 'The build failed because the process exited too early. ' + |
51 | | - 'Someone might have called `kill` or `killall`, or the system could ' + |
52 | | - 'be shutting down.' |
| 33 | + 'Someone might have called `kill` or `killall`, or the system could ' + |
| 34 | + 'be shutting down.', |
53 | 35 | ); |
54 | 36 | } |
55 | 37 | process.exit(1); |
56 | 38 | } |
57 | 39 | process.exit(result.status); |
58 | 40 | } else { |
59 | | - console.log('Unknown script "' + script + '".'); |
| 41 | + console.log(`Unknown script "${script}".`); |
60 | 42 | console.log('Perhaps you need to update react-unity-scripts?'); |
61 | | - console.log( |
62 | | - 'See: https://github.com/KurtGokhan/react-unity-scripts.git' |
63 | | - ); |
| 43 | + console.log('See: https://github.com/KurtGokhan/react-unity-scripts.git'); |
64 | 44 | } |
0 commit comments