mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
fix: lost context in closures
This commit is contained in:
parent
6567c205c9
commit
a0ca257263
2
bin/nuxt
2
bin/nuxt
@ -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({
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ function startDev(oldInstance) {
|
||||
}
|
||||
})
|
||||
// Start build
|
||||
.then(builder.build)
|
||||
.then(() => builder.build())
|
||||
// Close old nuxt after successful build
|
||||
.then(
|
||||
() =>
|
||||
|
@ -53,4 +53,4 @@ generator
|
||||
.then(() => {
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(consola.fatal)
|
||||
.catch(err => consola.fatal(err))
|
||||
|
@ -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(
|
||||
|
@ -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())
|
||||
// }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user