()
| 129 | } |
| 130 | |
| 131 | function createWatcher () { |
| 132 | const nuxt = useNuxt() |
| 133 | const isIgnored = createIsIgnored(nuxt) |
| 134 | |
| 135 | const layerDirs = getLayerDirectories(nuxt) |
| 136 | const paths: string[] = [] |
| 137 | for (const layer of layerDirs) { |
| 138 | paths.push(layer.app) |
| 139 | // Only add server if it's not inside app (avoid double-watching) |
| 140 | if (!layer.server.startsWith(layer.app.replace(/\/?$/, '/'))) { |
| 141 | paths.push(layer.server) |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | const watcher = chokidarWatch(paths, { |
| 146 | ...nuxt.options.watchers.chokidar, |
| 147 | ignoreInitial: true, |
| 148 | ignored: [isIgnored, /[\\/]node_modules[\\/]/], |
| 149 | }) |
| 150 | |
| 151 | const restartPaths = new Set<string>() |
| 152 | const srcDir = nuxt.options.srcDir.replace(/\/?$/, '/') |
| 153 | for (const pattern of nuxt.options.watch) { |
| 154 | if (typeof pattern !== 'string') { continue } |
| 155 | const path = resolve(nuxt.options.srcDir, pattern) |
| 156 | if (!path.startsWith(srcDir)) { |
| 157 | restartPaths.add(path) |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | watcher.add([...restartPaths]) |
| 162 | |
| 163 | watcher.on('all', (event, path) => { |
| 164 | if (event === 'all' || event === 'ready' || event === 'error' || event === 'raw') { |
| 165 | return |
| 166 | } |
| 167 | nuxt.callHook('builder:watch', event, normalize(path)) |
| 168 | }) |
| 169 | nuxt.hook('close', () => watcher?.close()) |
| 170 | } |
| 171 | |
| 172 | function createGranularWatcher () { |
| 173 | const nuxt = useNuxt() |
no test coverage detected
searching dependent graphs…