-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_filter.ts
More file actions
34 lines (28 loc) · 981 Bytes
/
test_filter.ts
File metadata and controls
34 lines (28 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Glob } from 'bun';
const patterns = [
"openspec/changes/archive",
"**/design.md"
];
const files = [
"openspec/changes/improve-review-tracking/design.md",
"openspec/changes/improve-review-tracking/proposal.md",
"openspec/changes/improve-review-tracking/specs/agent-command/spec.md",
"openspec/changes/improve-review-tracking/specs/log-management/spec.md"
];
const globs: Glob[] = [];
const prefixes: string[] = [];
for (const pattern of patterns) {
if (pattern.match(/[*?[{]/)) {
globs.push(new Glob(pattern));
} else {
prefixes.push(pattern);
}
}
console.log('Prefixes:', prefixes);
console.log('Globs:', globs.map(g => g.pattern));
for (const file of files) {
const prefixMatch = prefixes.some((p) => file === p || file.startsWith(`${p}/`));
const globMatch = globs.some((g) => g.match(file));
const isExcluded = prefixMatch || globMatch;
console.log(`${file}: prefix=${prefixMatch}, glob=${globMatch}, excluded=${isExcluded}`);
}