Exclude items by shell pattern as well as by name
Docs / docs (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s

Patterns such as `.*` or `@*` are matched against an item's own name
with `fnmatch`, in the same places as excluded names: resolving a
tree, extending a watch to a directory that appears later, and
delivering events. Dependents that prune large trees can now skip
whole families of directories without listing each name.
This commit is contained in:
T. R. Bernstein
2026-09-16 11:21:45 +02:00
parent 442053eae2
commit 8af25be549
10 changed files with 154 additions and 22 deletions
@@ -11,10 +11,12 @@ func getEventsForTrigger(
mask: InotifyEventMask,
recursive: RecursivKind = .nonrecursive,
exclude: [String] = [],
excludePatterns: [String] = [],
trigger: @escaping (String) async throws -> Void,
) async throws -> [InotifyEvent] {
let watcher = try Inotify()
await watcher.exclude(names: exclude)
await watcher.exclude(patterns: excludePatterns)
switch recursive {
case .nonrecursive:
try await watcher.addWatch(path: dir, mask: mask)