mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-11 14:57:15 +00:00
fix(builder): call watch:restart
after watch:fileChanged
hook (#5620)
This commit is contained in:
parent
f831126e27
commit
9fb720d518
@ -663,12 +663,12 @@ export default class Builder {
|
||||
this.createFileWatcher(
|
||||
nuxtRestartWatch,
|
||||
['all'],
|
||||
(event, fileName) => {
|
||||
async (event, fileName) => {
|
||||
if (['add', 'change', 'unlink'].includes(event) === false) {
|
||||
return
|
||||
}
|
||||
this.nuxt.callHook('watch:fileChanged', this, fileName) // Legacy
|
||||
this.nuxt.callHook('watch:restart', { event, path: fileName })
|
||||
await this.nuxt.callHook('watch:fileChanged', this, fileName) // Legacy
|
||||
await this.nuxt.callHook('watch:restart', { event, path: fileName })
|
||||
},
|
||||
this.assignWatcher('restart')
|
||||
)
|
||||
|
@ -244,7 +244,7 @@ describe('builder: builder watch', () => {
|
||||
expect(chokidar.on).toBeCalledWith('all', expect.any(Function))
|
||||
})
|
||||
|
||||
test('should trigger restarting when files changed', () => {
|
||||
test('should trigger restarting when files changed', async () => {
|
||||
const nuxt = createNuxt()
|
||||
nuxt.options.watchers = {
|
||||
chokidar: { test: true }
|
||||
@ -259,9 +259,9 @@ describe('builder: builder watch', () => {
|
||||
|
||||
const restartHandler = chokidar.on.mock.calls[0][1]
|
||||
const watchingFile = '/var/nuxt/src/watch/test/index.js'
|
||||
restartHandler('add', watchingFile)
|
||||
restartHandler('change', watchingFile)
|
||||
restartHandler('unlink', watchingFile)
|
||||
await restartHandler('add', watchingFile)
|
||||
await restartHandler('change', watchingFile)
|
||||
await restartHandler('unlink', watchingFile)
|
||||
|
||||
expect(nuxt.callHook).toBeCalledTimes(6)
|
||||
expect(nuxt.callHook).nthCalledWith(1, 'watch:fileChanged', builder, watchingFile)
|
||||
|
Loading…
Reference in New Issue
Block a user