in SourceKitStressTester/Package.swift [16:41]
func getConfigParam(_ name: String) -> String? {
if let envValue = ProcessInfo.processInfo.environment[name] {
return envValue
}
let configFile = URL(fileURLWithPath: #filePath)
.deletingLastPathComponent()
.appendingPathComponent("Package-config.json")
let configData: Data
do {
configData = try Data(contentsOf: configFile)
} catch {
// Config file not found. That's fine. Return `nil` without complaining.
return nil
}
do {
let config = try JSONDecoder().decode([String: String].self, from: configData)
return config[name]
} catch {
// We couldn't parse the Package-config.json, probably malformatted JSON.
// Print the error, which shows up as a warning in Xcode.
print("Loading Package-config.json failed with error: \(error)")
return nil
}
}