@techninja/clearstack 0.4.11 → 0.4.12
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/lib/spec-config.js +13 -2
- package/lib/watch-lifecycle.js +1 -1
- package/lib/watch-runner.js +2 -2
- package/lib/watch.js +1 -1
- package/package.json +1 -1
package/lib/spec-config.js
CHANGED
|
@@ -67,8 +67,9 @@ export const FAST_CHECKS = new Set(['lines', 'docs', 'imports', 'i18n', 'tests']
|
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Build ext→keys map, merging EXT_DEFAULTS with `watchExts` declared on extension checks.
|
|
70
|
+
* Checks may also declare `watchPaths: string[]` to scope triggers to specific path prefixes.
|
|
70
71
|
* @param {object[]} checks
|
|
71
|
-
* @returns {(ext: string) => string[]}
|
|
72
|
+
* @returns {(ext: string, filepath?: string) => string[]}
|
|
72
73
|
*/
|
|
73
74
|
export function makeExtMap(checks) {
|
|
74
75
|
const map = new Map(Object.entries(EXT_DEFAULTS).map(([k, v]) => [k, new Set(v)]));
|
|
@@ -79,7 +80,17 @@ export function makeExtMap(checks) {
|
|
|
79
80
|
map.get(ext).add(c.key);
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
+
const pathScoped = checks.filter((c) => c.watchPaths?.length);
|
|
84
|
+
return (ext, filepath) => {
|
|
85
|
+
let keys = [...(map.get(ext) ?? [])];
|
|
86
|
+
if (filepath && pathScoped.length) {
|
|
87
|
+
keys = keys.filter((k) => {
|
|
88
|
+
const c = pathScoped.find((p) => p.key === k);
|
|
89
|
+
return !c || c.watchPaths.some((p) => filepath.startsWith(p));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return keys;
|
|
93
|
+
};
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
/**
|
package/lib/watch-lifecycle.js
CHANGED
|
@@ -37,7 +37,7 @@ export function setupLifecycle(ctx) {
|
|
|
37
37
|
|
|
38
38
|
for (const dir of watchDirs) {
|
|
39
39
|
watch(resolve(projectDir, dir), { recursive: true }, (_event, filename) => {
|
|
40
|
-
if (filename) schedule(extname(filename));
|
|
40
|
+
if (filename) schedule(extname(filename), filename);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
package/lib/watch-runner.js
CHANGED
|
@@ -61,9 +61,9 @@ let fixing = false;
|
|
|
61
61
|
/**
|
|
62
62
|
*
|
|
63
63
|
*/
|
|
64
|
-
export function schedule(specRows, ctx, pending, timers, run, checksForExt, ext) {
|
|
64
|
+
export function schedule(specRows, ctx, pending, timers, run, checksForExt, ext, filepath) {
|
|
65
65
|
if (fixing) return;
|
|
66
|
-
for (const k of checksForExt(ext)) {
|
|
66
|
+
for (const k of checksForExt(ext, filepath)) {
|
|
67
67
|
const row = specRows.find((r) => r.key === k);
|
|
68
68
|
if (row) row.pass = null;
|
|
69
69
|
if (FAST_CHECKS.has(k)) pending.fast.add(k);
|
package/lib/watch.js
CHANGED
|
@@ -62,7 +62,7 @@ export async function startWatch(projectDir) {
|
|
|
62
62
|
|
|
63
63
|
setupLifecycle({
|
|
64
64
|
serverRow, specRows, projectDir, watchDirs,
|
|
65
|
-
schedule: (ext) => schedule(specRows, ctx, pending, timers, run, checksForExt, ext),
|
|
65
|
+
schedule: (ext, filepath) => schedule(specRows, ctx, pending, timers, run, checksForExt, ext, filepath),
|
|
66
66
|
renderNote: () => renderNote(rows, lastCheck.value, watchDirs),
|
|
67
67
|
});
|
|
68
68
|
}
|
package/package.json
CHANGED