cwresdev 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/server.js +43 -1
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -298,9 +298,51 @@ async function startDevServer(config) {
|
|
|
298
298
|
});
|
|
299
299
|
|
|
300
300
|
let reloadTimer = null;
|
|
301
|
+
const ignored = (config.watchIgnored || []).map((pattern) => {
|
|
302
|
+
if (typeof pattern === "function") return pattern;
|
|
303
|
+
if (pattern instanceof RegExp) return pattern;
|
|
304
|
+
if (typeof pattern !== "string") return () => false;
|
|
305
|
+
|
|
306
|
+
const normalized = pattern.replace(/\\/g, "/");
|
|
307
|
+
|
|
308
|
+
// **/segment/** → match paths containing /segment/
|
|
309
|
+
if (normalized.startsWith("**/") && normalized.endsWith("/**")) {
|
|
310
|
+
const segment = normalized.slice(3, -3);
|
|
311
|
+
return (filePath) => filePath.replace(/\\/g, "/").includes(`/${segment}/`);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (normalized.startsWith("**/")) {
|
|
315
|
+
const tail = normalized.slice(3);
|
|
316
|
+
|
|
317
|
+
// **/*suffix → basename ends with suffix (e.g. **/*~)
|
|
318
|
+
if (tail.startsWith("*")) {
|
|
319
|
+
const suffix = tail.slice(1);
|
|
320
|
+
return (filePath) => path.basename(filePath).endsWith(suffix);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// **/prefix* → basename starts with prefix (e.g. **/~*)
|
|
324
|
+
if (tail.endsWith("*") && !tail.slice(0, -1).includes("*")) {
|
|
325
|
+
const prefix = tail.slice(0, -1);
|
|
326
|
+
return (filePath) => path.basename(filePath).startsWith(prefix);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// **/*.ext → match by extension (e.g. **/*.tmp)
|
|
330
|
+
if (tail.includes("*.")) {
|
|
331
|
+
const ext = tail.slice(tail.indexOf("*.") + 1);
|
|
332
|
+
return (filePath) => path.basename(filePath).endsWith(ext);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// **/name or **/dir/name → match end of path (e.g. **/Thumbs.db, **/data/.xml)
|
|
336
|
+
return (filePath) => filePath.replace(/\\/g, "/").endsWith(`/${tail}`);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// No glob metacharacters: exact match
|
|
340
|
+
return (filePath) => filePath.replace(/\\/g, "/") === normalized;
|
|
341
|
+
});
|
|
342
|
+
|
|
301
343
|
const watcher = chokidar.watch(config.docRoot, {
|
|
302
344
|
ignoreInitial: true,
|
|
303
|
-
ignored
|
|
345
|
+
ignored,
|
|
304
346
|
});
|
|
305
347
|
|
|
306
348
|
watcher.on("all", (eventName, filePath) => {
|