From bb0a3acaabcab7ece547c73f59bdcbf1fb6c33e2 Mon Sep 17 00:00:00 2001 From: Jake Langford Date: Sat, 29 Jun 2024 08:36:13 +0100 Subject: [PATCH] Fix linting with stdin (#1744) --- Sources/CommandLine.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/CommandLine.swift b/Sources/CommandLine.swift index 0ac4758b..3e31001f 100644 --- a/Sources/CommandLine.swift +++ b/Sources/CommandLine.swift @@ -707,9 +707,16 @@ func processArguments(_ args: [String], environment: [String: String] = [:], in if !dryrun, (try? String(contentsOf: outputURL)) != output { try write(output, to: outputURL) } - } else { + } else if !lint { // Write to stdout print(dryrun ? input : output, as: .raw) + } else if let reporterOutput = try reporter.write() { + if let reportURL = reportURL { + print("Writing report file to \(reportURL.path)", as: .info) + try reporterOutput.write(to: reportURL, options: .atomic) + } else { + print(String(decoding: reporterOutput, as: UTF8.self), as: .raw) + } } let exitCode: ExitCode if lint, output != input { @@ -794,7 +801,7 @@ func processArguments(_ args: [String], environment: [String: String] = [:], in } if let reporterOutput = try reporter.write() { if let reportURL = reportURL { - print("Writing report file to \(reportURL.path)") + print("Writing report file to \(reportURL.path)", as: .info) try reporterOutput.write(to: reportURL, options: .atomic) } else { print(String(decoding: reporterOutput, as: UTF8.self), as: .raw)