-
-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exit with code 1 when build fails #55
Conversation
This is probably a breaking change, if people relied on the fact that backback exited with code 0 on failure. |
This is from another project we use internally... will this work? ....
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
throw err;
});
compile(serverConfig, (err, serverStats) => {
handleWebpackErrors(err, serverStats)
console.log(chalk.green('Compiled successfully'))
})
// Wrap webpack compile in a try catch.
function compile(config, cb) {
let compiler;
try {
compiler = webpack(config);
} catch (e) {
printErrors('Failed to compile.', [e]);
process.exit(1);
}
compiler.run((err, stats) => {
cb(err, stats);
});
}
// Print out errors
function printErrors(summary, errors) {
console.log(chalk.red(summary));
console.log();
errors.forEach(err => {
console.log(err.message || err);
console.log();
});
}
// Gracefully handle errors and print them to console.
function handleWebpackErrors(err, stats) {
if (err) {
printErrors('Failed to compile.', [err]);
process.exit(1);
}
if (stats.compilation.errors && stats.compilation.errors.length) {
printErrors('Failed to compile.', stats.compilation.errors);
process.exit(1);
}
if (
process.env.CI &&
stats.compilation.warnings &&
stats.compilation.warnings.length
) {
printErrors(
'Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.',
stats.compilation.warnings
);
process.exit(1);
}
} |
@jaredpalmer Yeah that works as well, but it will duplicate the output in the error case: |
@despairblue yeah, i pulled it from a project that has a custom webpack logging plugin. Forgot that backpack has that totally baked in tbh. |
@jaredpalmer So how are we going to proceed from here? 😄 |
@jaredpalmer hey, is anything holding back a new release? Can I help somehow? |
@despairblue done. |
You are awesome, I was just running 👏 |
fixes #54