@@ -8,6 +8,18 @@ private let ignoreRegex = try Regex(#"// *@ignore-import$"#)
8
8
private var cachedLines = [ String: [ String . SubSequence] ] ( )
9
9
10
10
private 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
+
11
23
let ignoredFileRegex : Regex < AnyRegexOutput > ?
12
24
let ignoredModuleRegex : Regex < AnyRegexOutput > ?
13
25
let alwaysKeepImports : Set < String >
@@ -144,7 +156,7 @@ private func collectUnitsAndRecords(indexStorePath: String) -> [(UnitReader, Rec
144
156
}
145
157
146
158
private func main(
147
- indexStorePath : String ,
159
+ indexStorePaths : [ String ] ,
148
160
configuration: Configuration )
149
161
{
150
162
if let directory = ProcessInfo . processInfo. environment [ " BUILD_WORKSPACE_DIRECTORY " ] {
@@ -153,7 +165,7 @@ private func main(
153
165
154
166
let pwd = FileManager . default. currentDirectoryPath
155
167
var filesToDefinitions : [ String : References ] = [ : ]
156
- let unitsAndRecords = collectUnitsAndRecords ( indexStorePath: indexStorePath )
168
+ let unitsAndRecords = indexStorePaths . flatMap ( collectUnitsAndRecords ( indexStorePath: ) )
157
169
var modulesToUnits : [ String : [ UnitReader ] ] = [ : ]
158
170
var allModuleNames = Set < String > ( )
159
171
@@ -230,17 +242,15 @@ private func main(
230
242
}
231
243
}
232
244
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) {
237
247
main (
238
- indexStorePath : CommandLine . arguments [ 2 ] ,
248
+ indexStorePaths : Array ( arguments. dropFirst ( ) ) ,
239
249
configuration: configuration
240
250
)
241
251
} else {
242
252
main (
243
- indexStorePath : CommandLine . arguments [ 1 ] ,
253
+ indexStorePaths : Array ( arguments) ,
244
254
configuration: Configuration ( )
245
255
)
246
256
}
0 commit comments