MCPcopy
hub / github.com/nuxt/nuxt / resolvePathsToWatch

Function resolvePathsToWatch

packages/nuxt/src/core/builder.ts:327–357  ·  view source on GitHub ↗
(nuxt: Nuxt, opts: { parentDirectories?: boolean } = {})

Source from the content-addressed store, hash-verified

325}
326
327function resolvePathsToWatch (nuxt: Nuxt, opts: { parentDirectories?: boolean } = {}): Set<string> {
328 const pathsToWatch = new Set<string>()
329 for (const dirs of getLayerDirectories(nuxt)) {
330 if (!isIgnored(dirs.app)) {
331 pathsToWatch.add(dirs.app)
332 }
333 // Only add server if it's not inside app (avoid double-watching)
334 if (!isIgnored(dirs.server) && !dirs.server.startsWith(dirs.app.replace(/\/?$/, '/'))) {
335 pathsToWatch.add(dirs.server)
336 }
337 }
338 for (const pattern of nuxt.options.watch) {
339 if (typeof pattern !== 'string') { continue }
340 const path = opts?.parentDirectories
341 ? join(dirname(resolve(nuxt.options.srcDir, pattern)), '')
342 : resolve(nuxt.options.srcDir, pattern)
343 let shouldAdd = true
344 for (const w of [...pathsToWatch]) {
345 if (w.startsWith(path)) {
346 pathsToWatch.delete(w)
347 }
348 if (path.startsWith(w)) {
349 shouldAdd = false
350 }
351 }
352 if (shouldAdd) {
353 pathsToWatch.add(path)
354 }
355 }
356 return pathsToWatch
357}

Callers 2

createGranularWatcherFunction · 0.85
createParcelWatcherFunction · 0.85

Calls 2

getLayerDirectoriesFunction · 0.90
isIgnoredFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…