Exit with code 1 on build error

This commit is contained in:
Sébastien Chopin 2017-01-20 18:55:30 +01:00
parent 55f907877e
commit e016b5d184
2 changed files with 3 additions and 1 deletions

View File

@ -27,5 +27,5 @@ nuxt.generate()
}) })
.catch((err) => { .catch((err) => {
console.error(err) // eslint-disable-line no-console console.error(err) // eslint-disable-line no-console
process.exit() process.exit(1)
}) })

View File

@ -337,6 +337,7 @@ function webpackRunClient () {
serverCompiler.run((err, stats) => { serverCompiler.run((err, stats) => {
if (err) return reject(err) if (err) return reject(err)
console.log('[nuxt:build:client]\n', stats.toString({ chunks: false, colors: true })) // eslint-disable-line no-console console.log('[nuxt:build:client]\n', stats.toString({ chunks: false, colors: true })) // eslint-disable-line no-console
if (stats.hasErrors()) return reject('Webpack build exited with errors')
resolve() resolve()
}) })
}) })
@ -349,6 +350,7 @@ function webpackRunServer () {
serverCompiler.run((err, stats) => { serverCompiler.run((err, stats) => {
if (err) return reject(err) if (err) return reject(err)
console.log('[nuxt:build:server]\n', stats.toString({ chunks: false, colors: true })) // eslint-disable-line no-console console.log('[nuxt:build:server]\n', stats.toString({ chunks: false, colors: true })) // eslint-disable-line no-console
if (stats.hasErrors()) return reject('Webpack build exited with errors')
const bundlePath = join(serverConfig.output.path, serverConfig.output.filename) const bundlePath = join(serverConfig.output.path, serverConfig.output.filename)
readFile(bundlePath, 'utf8') readFile(bundlePath, 'utf8')
.then((bundle) => { .then((bundle) => {