Skip to content

Commit f36d61a

Browse files
andrelmlinsmrmckeb
authored andcommitted
Remove switch case (#7729)
1 parent 71946b1 commit f36d61a

File tree

1 file changed

+29
-36
lines changed

1 file changed

+29
-36
lines changed

packages/react-scripts/bin/react-scripts.js

+29-36
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,35 @@ const scriptIndex = args.findIndex(
2424
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
2525
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
2626

27-
switch (script) {
28-
case 'build':
29-
case 'eject':
30-
case 'start':
31-
case 'test': {
32-
const result = spawn.sync(
33-
'node',
34-
nodeArgs
35-
.concat(require.resolve('../scripts/' + script))
36-
.concat(args.slice(scriptIndex + 1)),
37-
{ stdio: 'inherit' }
38-
);
39-
if (result.signal) {
40-
if (result.signal === 'SIGKILL') {
41-
console.log(
42-
'The build failed because the process exited too early. ' +
43-
'This probably means the system ran out of memory or someone called ' +
44-
'`kill -9` on the process.'
45-
);
46-
} else if (result.signal === 'SIGTERM') {
47-
console.log(
48-
'The build failed because the process exited too early. ' +
49-
'Someone might have called `kill` or `killall`, or the system could ' +
50-
'be shutting down.'
51-
);
52-
}
53-
process.exit(1);
27+
if (['build', 'eject', 'start', 'test'].includes(script)) {
28+
const result = spawn.sync(
29+
'node',
30+
nodeArgs
31+
.concat(require.resolve('../scripts/' + script))
32+
.concat(args.slice(scriptIndex + 1)),
33+
{ stdio: 'inherit' }
34+
);
35+
if (result.signal) {
36+
if (result.signal === 'SIGKILL') {
37+
console.log(
38+
'The build failed because the process exited too early. ' +
39+
'This probably means the system ran out of memory or someone called ' +
40+
'`kill -9` on the process.'
41+
);
42+
} else if (result.signal === 'SIGTERM') {
43+
console.log(
44+
'The build failed because the process exited too early. ' +
45+
'Someone might have called `kill` or `killall`, or the system could ' +
46+
'be shutting down.'
47+
);
5448
}
55-
process.exit(result.status);
56-
break;
49+
process.exit(1);
5750
}
58-
default:
59-
console.log('Unknown script "' + script + '".');
60-
console.log('Perhaps you need to update react-scripts?');
61-
console.log(
62-
'See: https://facebook.github.io/create-react-app/docs/updating-to-new-releases'
63-
);
64-
break;
51+
process.exit(result.status);
52+
} else {
53+
console.log('Unknown script "' + script + '".');
54+
console.log('Perhaps you need to update react-scripts?');
55+
console.log(
56+
'See: https://facebook.github.io/create-react-app/docs/updating-to-new-releases'
57+
);
6558
}

0 commit comments

Comments
 (0)