Skip to content

Commit 135d60e

Browse files
committed
Simplify findNonSourceFiles, fix its documentation
1 parent 20d3f51 commit 135d60e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Sources/Xcodeproj/generate().swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ public func generate(
7474
// Find non-source files in the source directories and root that should be added
7575
// as a reference to the project.
7676
var extraFiles = try findNonSourceFiles(path: srcroot)
77-
if let sourcesExtraFiles = try? findNonSourceFiles(path: srcroot.appending(component: "Sources"), recursively: true) {
78-
extraFiles.append(contentsOf: sourcesExtraFiles)
79-
}
80-
if let testsExtraFiles = try? findNonSourceFiles(path: srcroot.appending(component: "Tests"), recursively: true) {
81-
extraFiles.append(contentsOf: testsExtraFiles)
82-
}
77+
let sourcesExtraFiles = try findNonSourceFiles(path: srcroot.appending(component: "Sources"), recursively: true)
78+
extraFiles.append(contentsOf: sourcesExtraFiles)
79+
let testsExtraFiles = try findNonSourceFiles(path: srcroot.appending(component: "Tests"), recursively: true)
80+
extraFiles.append(contentsOf: testsExtraFiles)
8381

8482
// Get the ignored files and exclude them
8583
let ignoredFiles = try repositoryProvider.openCheckout(at: srcroot).getIgnoredFiles()
@@ -200,15 +198,17 @@ func findDirectoryReferences(path: AbsolutePath) throws -> [AbsolutePath] {
200198
})
201199
}
202200

203-
/// Finds the non-source files from `path` recursively
201+
/// Finds the non-source files from `path`
202+
/// - parameters:
203+
/// - path: The path of the directory to get the files from
204+
/// - recursively: Specifies if the directory at `path` should be searched recursively
204205
func findNonSourceFiles(path: AbsolutePath, recursively: Bool = false) throws -> [AbsolutePath] {
205206
let filesFromPath = try walk(path, recursively: recursively)
206207

207208
return filesFromPath.filter {
208209
if !isFile($0) { return false }
209-
if let `extension` = $0.extension {
210-
if SupportedLanguageExtension.cFamilyExtensions.contains(`extension`) { return false }
211-
if SupportedLanguageExtension.swiftExtensions.contains(`extension`) { return false }
210+
if let `extension` = $0.extension, SupportedLanguageExtension.validExtensions.contains(`extension`) {
211+
return false
212212
}
213213
return true
214214
}

0 commit comments

Comments
 (0)