diff --git a/Sources/SwiftDoc/Module.swift b/Sources/SwiftDoc/Module.swift index aa9d2aaf..ee8d1125 100644 --- a/Sources/SwiftDoc/Module.swift +++ b/Sources/SwiftDoc/Module.swift @@ -22,27 +22,31 @@ public final class Module { let fileManager = FileManager.default for path in paths { let directory = URL(fileURLWithPath: path) - guard let directoryEnumerator = fileManager.enumerator(at: directory, includingPropertiesForKeys: [.isDirectoryKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else { continue } + guard let directoryEnumerator = fileManager.enumerator(at: directory, + includingPropertiesForKeys: [.isDirectoryKey], + options: [.skipsHiddenFiles, .skipsPackageDescendants]) + else { continue } + + let ignoredDirectories: Set = Set([ + "node_modules", + "Packages", + "Pods", + "Resources", + "Tests" + ].map { directory.appendingPathComponent($0) }) + for case let url as URL in directoryEnumerator { - var isDirectory: ObjCBool = false guard url.pathExtension == "swift", - fileManager.isReadableFile(atPath: url.path), - fileManager.fileExists(atPath: url.path, isDirectory: &isDirectory) + fileManager.isReadableFile(atPath: url.path) else { - // Skip top-level Tests directory - if isDirectory.boolValue == true, - url.lastPathComponent == "Tests", - directory.appendingPathComponent("Tests").path == url.path - { + if ignoredDirectories.contains(url) { directoryEnumerator.skipDescendants() } continue } - if isDirectory.boolValue == false { - sources.append((url, directory)) - } + sources.append((url, directory)) } }