@@ -8,6 +8,18 @@ private let ignoreRegex = try Regex(#"// *@ignore-import$"#)
88private var cachedLines = [ String: [ String . SubSequence] ] ( )
99
1010private struct Configuration : Decodable {
11+ static func attemptingPath( _ path: String ? ) -> Configuration ? {
12+ guard let path else { return nil }
13+ do {
14+ return try JSONDecoder ( ) . decode (
15+ Configuration . self,
16+ from: try Data ( contentsOf: URL ( fileURLWithPath: path) )
17+ )
18+ } catch {
19+ return nil
20+ }
21+ }
22+
1123 let ignoredFileRegex : Regex < AnyRegexOutput > ?
1224 let ignoredModuleRegex : Regex < AnyRegexOutput > ?
1325 let alwaysKeepImports : Set < String >
@@ -144,7 +156,7 @@ private func collectUnitsAndRecords(indexStorePath: String) -> [(UnitReader, Rec
144156}
145157
146158private func main(
147- indexStorePath : String ,
159+ indexStorePaths : [ String ] ,
148160 configuration: Configuration )
149161{
150162 if let directory = ProcessInfo . processInfo. environment [ " BUILD_WORKSPACE_DIRECTORY " ] {
@@ -153,7 +165,7 @@ private func main(
153165
154166 let pwd = FileManager . default. currentDirectoryPath
155167 var filesToDefinitions : [ String : References ] = [ : ]
156- let unitsAndRecords = collectUnitsAndRecords ( indexStorePath: indexStorePath )
168+ let unitsAndRecords = indexStorePaths . flatMap ( collectUnitsAndRecords ( indexStorePath: ) )
157169 var modulesToUnits : [ String : [ UnitReader ] ] = [ : ]
158170 var allModuleNames = Set < String > ( )
159171
@@ -230,17 +242,15 @@ private func main(
230242 }
231243}
232244
233- if CommandLine . arguments. count == 3 {
234- let configurationData = try ! Data ( contentsOf: URL ( fileURLWithPath: CommandLine . arguments [ 1 ] ) )
235- let configuration = try ! JSONDecoder ( ) . decode ( Configuration . self, from: configurationData)
236-
245+ let arguments = CommandLine . arguments. dropFirst ( )
246+ if let configuration = Configuration . attemptingPath ( arguments. first) {
237247 main (
238- indexStorePath : CommandLine . arguments [ 2 ] ,
248+ indexStorePaths : Array ( arguments. dropFirst ( ) ) ,
239249 configuration: configuration
240250 )
241251} else {
242252 main (
243- indexStorePath : CommandLine . arguments [ 1 ] ,
253+ indexStorePaths : Array ( arguments) ,
244254 configuration: Configuration ( )
245255 )
246256}
0 commit comments