mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-06-16 10:34:34 +00:00
Added logging of config file location
This commit is contained in:
@@ -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)")
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user