mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-23 12:48:00 +08:00
Make build exit with error code when interrupted (#1496)
* Make build exit with error code when interrupted This addresses issue #1493. Current behavior is that `npm run build` exits code 0 without creating a bundle when interrupted. This change makes the build script catch catchable interruptions and exit with the appropriate error code. * Better error messages for kill signals * Don't catch SIGINT Ctrl+C should exit silently, and already produces a non-zero exit code when sent to the console while `npm run build` is running. Exit code 0 is produced if SIGINT is sent directly to the `node build.js` process, but this is unlikely to happen. A SIGINT handler in `build.js` will also be triggered by Ctrl+C in the console, potentially producing unnecessary noise. * Style fix * No changes needed to build.js Problem is coming from the parent process, `react-scripts` * Make react-scripts script handle signals * Clarify context
This commit is contained in:
committed by
Dan Abramov
parent
7a02f9a41a
commit
e19b0f6373
16
packages/react-scripts/bin/react-scripts.js
vendored
16
packages/react-scripts/bin/react-scripts.js
vendored
@@ -13,6 +13,22 @@ case 'test':
|
||||
[require.resolve('../scripts/' + script)].concat(args),
|
||||
{stdio: 'inherit'}
|
||||
);
|
||||
if (result.signal) {
|
||||
if (result.signal == 'SIGKILL') {
|
||||
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.'
|
||||
);
|
||||
} else if (result.signal == 'SIGTERM') {
|
||||
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);
|
||||
}
|
||||
process.exit(result.status);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user