Added logging of config file location

This commit is contained in:
Nick Lockwood
2020-05-28 01:19:17 +01:00
parent af50864b61
commit d7d3d74b53
2 changed files with 18 additions and 7 deletions
+13 -7
View File
@@ -675,7 +675,11 @@ func inferOptions(from inputURLs: [URL], options: FileOptions) -> (Int, FormatOp
var filesParsed = 0
let baseOptions = Options(fileOptions: options)
for inputURL in inputURLs {
errors += enumerateFiles(withInputURL: inputURL, options: baseOptions) { inputURL, _, _ in
errors += enumerateFiles(
withInputURL: inputURL,
options: baseOptions,
logger: { print($0, as: .info) }
) { inputURL, _, _ in
guard let input = try? String(contentsOf: inputURL) else {
throw FormatError.reading("Failed to read file \(inputURL.path)")
}
@@ -784,12 +788,14 @@ func processInput(_ inputURLs: [URL],
// Format files
var errors = [Error]()
for inputURL in inputURLs {
errors += enumerateFiles(withInputURL: inputURL,
outputURL: outputURL,
options: options,
concurrent: !verbose,
skipped: skippedHandler) { inputURL, outputURL, options in
errors += enumerateFiles(
withInputURL: inputURL,
outputURL: outputURL,
options: options,
concurrent: !verbose,
logger: { print($0, as: .info) },
skipped: skippedHandler
) { inputURL, outputURL, options in
guard let input = try? String(contentsOf: inputURL) else {
throw FormatError.reading("Failed to read file \(inputURL.path)")
}
+5
View File
@@ -73,6 +73,9 @@ public typealias FileEnumerationHandler = (
_ options: Options
) throws -> () throws -> Void
/// Callback for info-level logging
public typealias Logger = (String) -> Void
/// Enumerate all swift files at the specified location and (optionally) calculate an output file URL for each.
/// Ignores the file if any of the excluded file URLs is a prefix of the input file URL.
///
@@ -86,6 +89,7 @@ public func enumerateFiles(withInputURL inputURL: URL,
outputURL: URL? = nil,
options baseOptions: Options = .default,
concurrent: Bool = true,
logger print: Logger? = nil,
skipped: FileEnumerationHandler? = nil,
handler: @escaping FileEnumerationHandler) -> [Error] {
let manager = FileManager.default
@@ -234,6 +238,7 @@ public func enumerateFiles(withInputURL inputURL: URL,
let data = try Data(contentsOf: configFile)
let args = try parseConfigFile(data)
try options.addArguments(args, in: inputURL.path)
print?("Reading config file at \(configFile.path)")
}
let versionFile = inputURL.appendingPathComponent(swiftVersionFile)
if manager.fileExists(atPath: versionFile.path) {