fix(cli): remove duplicate error message in start and build (#4258)

This commit is contained in:
Clark Du 2018-11-02 13:54:58 +00:00 committed by Pooya Parsa
parent 12151d81d6
commit 17e0890c90
4 changed files with 5 additions and 11 deletions

View File

@ -56,9 +56,6 @@ export default {
await cmd.getNuxtConfig(argv, { dev: false })
)
// Setup hooks
nuxt.hook('error', err => consola.fatal(err))
let builderOrGenerator
if (nuxt.options.mode !== 'spa' || argv.generate === false) {
// Build only

View File

@ -30,9 +30,6 @@ export default {
await cmd.getNuxtConfig(argv, { dev: false })
)
// Setup hooks
nuxt.hook('error', err => consola.fatal(err))
// Check if project is built for production
const distDir = path.resolve(
nuxt.options.rootDir,

View File

@ -34,8 +34,8 @@ export default class Hookable {
try {
await sequence(this._hooks[name], fn => fn(...args))
} catch (err) {
consola.error(err)
this.callHook('error', err)
name !== 'error' && this.callHook('error', err)
consola.fatal(err)
}
}

View File

@ -39,7 +39,7 @@ describe('error', () => {
})
test('Error: callHook()', async () => {
consola.error.mockClear()
consola.fatal.mockClear()
const errorHook = jest.fn()
const error = new Error('test hook error')
@ -50,8 +50,8 @@ describe('error', () => {
expect(errorHook).toHaveBeenCalledTimes(1)
expect(errorHook).toHaveBeenCalledWith(error)
expect(consola.error).toHaveBeenCalledTimes(1)
expect(consola.error).toHaveBeenCalledWith(error)
expect(consola.fatal).toHaveBeenCalledTimes(1)
expect(consola.fatal).toHaveBeenCalledWith(error)
})
// Close server and ask nuxt to stop listening to file changes