Exclude items by shell pattern as well as by name
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:
@@ -24,4 +24,14 @@ struct DirectoryResolverTests {
|
||||
#expect(directories.map { $0.description } == [dir])
|
||||
}
|
||||
}
|
||||
|
||||
@Test func doesNotDescendIntoDirectoriesMatchingAnExcludedPattern() async throws {
|
||||
try await withTempDir { dir in
|
||||
let excludedSubdirectory = "\(dir)/@eaDir/Inside"
|
||||
try FileManager.default.createDirectory(atPath: excludedSubdirectory, withIntermediateDirectories: true)
|
||||
let directories = try await DirectoryResolver.resolve([dir], excluding: ExclusionList(patterns: ["@*"]))
|
||||
|
||||
#expect(directories.map { $0.description } == [dir])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user