Skip to content

Commit 6e4c4b5

Browse files
authored
Merge pull request #829 from ahoppen/skip-dot-windows
Skip files and directories starting with `.` on Windows
2 parents b3314ac + f94d502 commit 6e4c4b5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/SwiftFormat/Utilities/FileIterator.swift

+8
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ public struct FileIterator: Sequence, IteratorProtocol {
113113
guard let item = dirIterator?.nextObject() as? URL else {
114114
break
115115
}
116+
#if os(Windows)
117+
// Windows does not consider files and directories starting with `.` as hidden but we don't want to traverse
118+
// into eg. `.build`. Manually skip any items starting with `.`.
119+
if item.lastPathComponent.hasPrefix(".") {
120+
dirIterator?.skipDescendants()
121+
continue
122+
}
123+
#endif
116124

117125
guard item.lastPathComponent.hasSuffix(fileSuffix), let fileType = fileType(at: item) else {
118126
continue

0 commit comments

Comments
 (0)