fix: lost context in closures

This commit is contained in:
Clark Du 2018-07-25 16:57:43 +01:00
parent 6567c205c9
commit a0ca257263
6 changed files with 9 additions and 9 deletions

View File

@ -4,7 +4,7 @@ const { join } = require('path')
const consola = require('consola')
// Global error handler
process.on('unhandledRejection', consola.error)
process.on('unhandledRejection', err => consola.error(err))
// Exit process on fatal errors
consola.add({

View File

@ -51,7 +51,7 @@ const nuxt = new Nuxt(options)
const builder = new Builder(nuxt)
// Setup hooks
nuxt.hook('error', consola.fatal)
nuxt.hook('error', err => consola.fatal(err))
// Close function
const close = () => {
@ -69,11 +69,11 @@ if (options.mode !== 'spa' || argv.generate === false) {
builder
.build()
.then(close)
.catch(consola.fatal)
.catch(err => consola.fatal(err))
} else {
// Build + Generate for static deployment
new Generator(nuxt, builder)
.generate({ build: true })
.then(close)
.catch(consola.fatal)
.catch(err => consola.fatal(err))
}

View File

@ -115,7 +115,7 @@ function startDev(oldInstance) {
}
})
// Start build
.then(builder.build)
.then(() => builder.build())
// Close old nuxt after successful build
.then(
() =>

View File

@ -53,4 +53,4 @@ generator
.then(() => {
process.exit(0)
})
.catch(consola.fatal)
.catch(err => consola.fatal(err))

View File

@ -52,7 +52,7 @@ options.dev = false
const nuxt = new Nuxt(options)
// Setup hooks
nuxt.hook('error', consola.fatal)
nuxt.hook('error', err => consola.fatal(err))
// Check if project is built for production
const distDir = resolve(

View File

@ -47,7 +47,7 @@ export default class Builder {
// Stop watching on nuxt.close()
if (this.options.dev) {
this.nuxt.hook('close', this.unwatch)
this.nuxt.hook('close', () => this.unwatch())
}
// Initialize shared FS and Cache
@ -57,7 +57,7 @@ export default class Builder {
// if(!this.options.dev) {
// TODO: enable again when unsafe concern resolved.(common/options.js:42)
// this.nuxt.hook('build:done', this.generateConfig)
// this.nuxt.hook('build:done', () => this.generateConfig())
// }
}