|
5 | 5 | /** |
6 | 6 | * External dependencies |
7 | 7 | */ |
8 | | -const spawn = require( 'cross-spawn' ); |
| 8 | +const spawn = require("cross-spawn"); |
9 | 9 |
|
10 | 10 | /** |
11 | 11 | * Internal dependencies |
12 | 12 | */ |
13 | | -const { |
14 | | - getArgs, |
15 | | -} = require( '../utils' ); |
16 | | - |
17 | | -const [ script, ...args ] = getArgs(); |
18 | | - |
19 | | -if ( ! [ |
20 | | - 'build', |
21 | | - 'lint-js', |
22 | | - 'lint-style', |
23 | | - 'start', |
24 | | -].includes( script ) ) { |
25 | | - if ( undefined === script ) { |
26 | | - console.log('No script specified.'); |
| 13 | +const { getArgs } = require("../utils"); |
| 14 | + |
| 15 | +const [script, ...args] = getArgs(); |
| 16 | + |
| 17 | +if (!["build", "lint-js", "lint-style", "start"].includes(script)) { |
| 18 | + if (undefined === script) { |
| 19 | + console.log("No script specified."); |
27 | 20 | } else { |
28 | 21 | console.log('Unknown script "' + script + '".'); |
29 | 22 | } |
30 | | - process.exit( 1 ); |
| 23 | + process.exit(1); |
31 | 24 | } |
32 | 25 |
|
33 | 26 | const { signal, status } = spawn.sync( |
34 | | - 'node', |
35 | | - [ |
36 | | - require.resolve( '../scripts/' + script ), |
37 | | - ...args, |
38 | | - ], |
39 | | - { stdio: 'inherit' } |
| 27 | + "node", |
| 28 | + [require.resolve("../scripts/" + script), ...args], |
| 29 | + { stdio: "inherit" } |
40 | 30 | ); |
41 | 31 |
|
42 | | -if ( signal ) { |
43 | | - if ( signal === 'SIGKILL' ) { |
| 32 | +if (signal) { |
| 33 | + if (signal === "SIGKILL") { |
44 | 34 | console.log( |
45 | | - 'The script failed because the process exited too early. ' + |
46 | | - 'This probably means the system ran out of memory or someone called ' + |
47 | | - '`kill -9` on the process.' |
| 35 | + "The script 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." |
48 | 38 | ); |
49 | | - } else if ( signal === 'SIGTERM' ) { |
| 39 | + } else if (signal === "SIGTERM") { |
50 | 40 | console.log( |
51 | | - 'The script failed because the process exited too early. ' + |
52 | | - 'Someone might have called `kill` or `killall`, or the system could ' + |
53 | | - 'be shutting down.' |
| 41 | + "The script failed because the process exited too early. " + |
| 42 | + "Someone might have called `kill` or `killall`, or the system could " + |
| 43 | + "be shutting down." |
54 | 44 | ); |
55 | 45 | } |
56 | | - process.exit( 1 ); |
| 46 | + process.exit(1); |
57 | 47 | } |
58 | 48 |
|
59 | | -process.exit( status ); |
| 49 | +process.exit(status); |
0 commit comments