Browse Source

Handling errors to properly fail builds

plugin-mode
Eli Perelman 8 years ago
parent
commit
117c9e90aa
  1. 44
      packages/neutrino/commands/build/index.js
  2. 4
      packages/neutrino/package.json

44
packages/neutrino/commands/build/index.js

@ -4,25 +4,43 @@ const getPreset = require('../../src/get-preset');
const DevServer = require('webpack-dev-server');
const webpack = require('webpack');
const handleErrors = (err, stats) => {
if (err) {
console.error(err.stack || err);
if (err.details) {
console.error(err.details);
}
return true;
}
const jsonStats = stats.toJson();
if (jsonStats.errors.length) {
jsonStats.errors.map(err => console.error(err));
return true;
}
return false;
};
const build = (config, done) => {
const compiler = webpack(config);
compiler.run((err, stats) => {
if (!err) {
console.log(stats.toString({
colors: true,
chunks: false,
children: false
}));
} else {
console.error(err.stack || err);
if (err.details) {
console.error(err.details);
}
const failed = handleErrors(err, stats);
if (failed) {
return done(1);
}
done();
console.log(stats.toString({
colors: true,
chunks: false,
children: false
}));
done(0);
});
};

4
packages/neutrino/package.json

@ -1,6 +1,6 @@
{
"name": "neutrino",
"version": "2.1.0",
"version": "2.2.0",
"description": "Create and build JS applications with managed configurations",
"main": "bin/neutrino",
"bin": {
@ -52,7 +52,7 @@
"resolve": "1.1.7",
"vorpal": "1.4.1",
"webpack": "1.13.2",
"webpack-dev-server": "1.15.2",
"webpack-dev-server": "1.16.2",
"webpack-hot-middleware": "2.12.2",
"webpack-merge": "0.14.1",
"yeoman-environment": "1.6.3"

Loading…
Cancel
Save