Skip to content

Commit

Permalink
minor refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM authored and nicklockwood committed Nov 11, 2023
1 parent 97928e5 commit c61c3c3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Plugins/SwiftFormatPlugin/SwiftFormatPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import PackagePlugin
if selectedTargets.isEmpty {
targetsToProcess = context.package.targets
} else {
targetsToProcess = try context.allLocalTargets(for: selectedTargets)
targetsToProcess = try context.package.allLocalTargets(of: selectedTargets)
}

for target in targetsToProcess {
Expand All @@ -60,10 +60,10 @@ import PackagePlugin
}
}

extension PluginContext {
func allLocalTargets(for targetNames: [String]) throws -> [Target] {
let matchingTargets = try self.package.targets(named: targetNames)
let packageTargets = Set(self.package.targets.map(\.id))
extension Package {
func allLocalTargets(of targetNames: [String]) throws -> [Target] {
let matchingTargets = try self.targets(named: targetNames)
let packageTargets = Set(self.targets.map(\.id))
let withLocalDependencies = matchingTargets.flatMap { [$0] + $0.recursiveTargetDependencies }
.filter { packageTargets.contains($0.id) }
let enumeratedKeyValues = withLocalDependencies.map(\.id).enumerated()
Expand Down

0 comments on commit c61c3c3

Please sign in to comment.