fix(nuxt-build): wait for use exit when running with --analyze flag

This commit is contained in:
Pooya Parsa 2018-01-14 14:04:45 +03:30
parent c4c63e0c66
commit c3bcda873c

View File

@ -75,12 +75,20 @@ const builder = new Builder(nuxt)
// Setup hooks // Setup hooks
nuxt.hook('error', (_err, from) => Utils.fatalError(_err, from)) nuxt.hook('error', (_err, from) => Utils.fatalError(_err, from))
// Close function
const close = () => {
if (options.build.analyze === true) {
return // Wait for user exit
}
process.exit(0)
}
if (options.mode !== 'spa') { if (options.mode !== 'spa') {
// -- Build for SSR app -- // -- Build for SSR app --
builder builder
.build() .build()
.then(() => debug('Building done')) .then(() => debug('Building done'))
.then(() => process.exit(0)) .then(() => close())
.catch(err => { .catch(err => {
Utils.fatalError(err) Utils.fatalError(err)
}) })
@ -110,6 +118,6 @@ if (options.mode !== 'spa') {
// Generate dist for SPA static deployment // Generate dist for SPA static deployment
new Generator(nuxt, builder).generate({ build: true }).then(() => { new Generator(nuxt, builder).generate({ build: true }).then(() => {
process.exit(0) close()
}) })
} }