mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 15:50:32 +00:00
fix(nuxt): normalize windows paths in granular watcher (#21066)
This commit is contained in:
parent
1879e1cd4d
commit
75cd6b7894
@ -5,7 +5,7 @@ import chokidar from 'chokidar'
|
|||||||
import { isIgnored, tryResolveModule, useNuxt } from '@nuxt/kit'
|
import { isIgnored, tryResolveModule, useNuxt } from '@nuxt/kit'
|
||||||
import { interopDefault } from 'mlly'
|
import { interopDefault } from 'mlly'
|
||||||
import { debounce } from 'perfect-debounce'
|
import { debounce } from 'perfect-debounce'
|
||||||
import { normalize } from 'pathe'
|
import { normalize, resolve } from 'pathe'
|
||||||
import type { Nuxt } from 'nuxt/schema'
|
import type { Nuxt } from 'nuxt/schema'
|
||||||
|
|
||||||
import { generateApp as _generateApp, createApp } from './app'
|
import { generateApp as _generateApp, createApp } from './app'
|
||||||
@ -96,8 +96,9 @@ function createGranularWatcher () {
|
|||||||
|
|
||||||
const ignoredDirs = new Set([...nuxt.options.modulesDir, nuxt.options.buildDir])
|
const ignoredDirs = new Set([...nuxt.options.modulesDir, nuxt.options.buildDir])
|
||||||
const pathsToWatch = nuxt.options._layers.map(layer => layer.config.srcDir).filter(d => d && !isIgnored(d))
|
const pathsToWatch = nuxt.options._layers.map(layer => layer.config.srcDir).filter(d => d && !isIgnored(d))
|
||||||
for (const path of nuxt.options.watch) {
|
for (const pattern of nuxt.options.watch) {
|
||||||
if (typeof path !== 'string') { continue }
|
if (typeof pattern !== 'string') { continue }
|
||||||
|
const path = resolve(nuxt.options.srcDir, pattern)
|
||||||
if (pathsToWatch.some(w => path.startsWith(w.replace(/[^/]$/, '$&/')))) { continue }
|
if (pathsToWatch.some(w => path.startsWith(w.replace(/[^/]$/, '$&/')))) { continue }
|
||||||
pathsToWatch.push(path)
|
pathsToWatch.push(path)
|
||||||
}
|
}
|
||||||
@ -107,8 +108,9 @@ function createGranularWatcher () {
|
|||||||
const watchers: Record<string, FSWatcher> = {}
|
const watchers: Record<string, FSWatcher> = {}
|
||||||
|
|
||||||
watcher.on('all', (event, path) => {
|
watcher.on('all', (event, path) => {
|
||||||
|
path = normalize(path)
|
||||||
if (!pending) {
|
if (!pending) {
|
||||||
nuxt.callHook('builder:watch', event, normalize(path))
|
nuxt.callHook('builder:watch', event, path)
|
||||||
}
|
}
|
||||||
if (event === 'unlinkDir' && path in watchers) {
|
if (event === 'unlinkDir' && path in watchers) {
|
||||||
watchers[path].close()
|
watchers[path].close()
|
||||||
|
Loading…
Reference in New Issue
Block a user