Skip to content

Commit

Permalink
Skip isFolder check for some extensions to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
kyounh12 committed Apr 16, 2024
1 parent c750e2d commit c32ca41
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Sources/TuistCore/Graph/ModelExtensions/Target+Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,16 @@ extension Target {
.subtracting(excluded)
.filter { path in
guard let `extension` = path.extension else { return false }

if FileHandler.shared.isFolder(path) {
// If path points to a directory, we need to check if extension is source compatible.
return Target.validSourceCompatibleFolderExtensions
.contains(where: { $0.caseInsensitiveCompare(`extension`) == .orderedSame })

let hasValidSourceExtensions = Target.validSourceExtensions
.contains(where: { $0.caseInsensitiveCompare(`extension`) == .orderedSame })

if hasValidSourceExtensions {
// Addition check to prevent folders with name like `Foo.Swift` to be considered as source files.
return !FileHandler.shared.isFolder(path)
} else {
return Target.validSourceExtensions
// There are extensions should be considered as source files even if they are folders.
return Target.validSourceCompatibleFolderExtensions
.contains(where: { $0.caseInsensitiveCompare(`extension`) == .orderedSame })
}
}
Expand Down

0 comments on commit c32ca41

Please sign in to comment.