Skip to content

Commit

Permalink
Only filter out folders that are not source compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
junseok-l2 committed Apr 16, 2024
1 parent 411ed75 commit 1f7c063
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
12 changes: 9 additions & 3 deletions Sources/TuistCore/Graph/ModelExtensions/Target+Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,15 @@ extension Target {
.subtracting(excluded)
.filter { path in
guard let `extension` = path.extension else { return false }
guard !FileHandler.shared.isFolder(path) else { return false }
return Target.validSourceExtensions
.contains(where: { $0.caseInsensitiveCompare(`extension`) == .orderedSame })

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 })
} else {
return Target.validSourceExtensions
.contains(where: { $0.caseInsensitiveCompare(`extension`) == .orderedSame })
}
}
.forEach { sourceFiles[$0] = SourceFile(
path: $0,
Expand Down
6 changes: 4 additions & 2 deletions Sources/TuistGraph/Models/Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ public struct Target: Equatable, Hashable, Comparable, Codable {

// Note: The `.docc` file type is technically both a valid source extension and folder extension
// in order to compile the documentation archive (including Tutorials, Articles, etc.)
public static let validSourceCompatibleFolderExtensions: [String] = [
"playground", "rcproject", "mlpackage", "docc", "xcmappingmodel",
]
public static let validSourceExtensions: [String] = [
"m", "swift", "mm", "cpp", "cc", "c", "d", "s", "intentdefinition", "xcmappingmodel", "metal", "mlmodel", "docc",
"playground", "rcproject", "mlpackage",
"m", "swift", "mm", "cpp", "cc", "c", "d", "s", "intentdefinition", "metal", "mlmodel",
]
public static let validFolderExtensions: [String] = [
"framework", "bundle", "app", "xcassets", "appiconset", "scnassets",
Expand Down
12 changes: 10 additions & 2 deletions Tests/TuistGraphTests/Models/TargetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,21 @@ final class TargetTests: TuistUnitTestCase {
"d",
"s",
"intentdefinition",
"xcmappingmodel",
"metal",
"mlmodel",
"docc",
]
)
}

func test_validSourceCompatibleFolderExtensions() {
XCTAssertEqual(
Target.validSourceCompatibleFolderExtensions,
[
"playground",
"rcproject",
"mlpackage",
"docc",
"xcmappingmodel",
]
)
}
Expand Down

0 comments on commit 1f7c063

Please sign in to comment.