8000 fix(nuxt): test `watch` paths against all layer `srcDir`s by userquin Β· Pull Request #22307 Β· nuxt/nuxt Β· GitHub
[go: up one dir, main page]

Skip to content

fix(nuxt): test watch paths against all layer srcDirs #22307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: check the path inside the layer
  • Loading branch information
userquin committed Jul 24, 2023
commit 45d55628fbdad98a1d9aba08980c9e6a420b58c8
4 changes: 3 additions & 1 deletion packages/nuxt/src/core/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,14 @@ async function initNuxt (nuxt: Nuxt) {
for (const layer of nuxt.options._layers) {
if (!layer.config.watch) { continue }
const normalizedPath = relative(layer.config.srcDir, path)
// not inside layer srcDir
if (normalizedPath.startsWith('..') || isAbsolute(normalizedPath)) { continue }
for (const pattern of await Promise.all(layer.config.watch)) {
if (typeof pattern === 'string') {
if (pattern === path || pattern === normalizedPath) { return nuxt.callHook('restart') }
continue
}
// @ts-expect-error: pattern is filtered
// @ts-expect-error: 'pattern' is possibly 'undefined'.ts(18048) => pattern is filtered
if (pattern.test(path) || pattern.test(normalizedPath)) { return nuxt.callHook('restart') }
}
}
Expand Down
0