Skip to content
This repository was archived by the owner on Aug 12, 2026. It is now read-only.

Commit b3f185b

Browse files
authored
Write the --write-results file when a scan produces no results (#1143)
1 parent f87c3f6 commit b3f185b

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
##### Bug Fixes
1414

1515
- Follow embedded bundle and plugin edges transitively in the generated Bazel scan rule so custom Bazel queries can avoid building incorrectly transitioned targets while still analyzing extension- and plugin-reachable code.
16+
- The `--write-results` file is now written even when a scan produces no results, instead of being left absent from a prior run.
1617

1718
## 3.7.4 (2026-04-26)
1819

Sources/Frontend/Commands/ScanCommand.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,24 +295,26 @@ struct ScanCommand: ParsableCommand {
295295
let formatter = outputFormat.formatter.init(configuration: configuration, logger: logger)
296296
let colored = outputFormat.supportsColoredOutput && logger.isColoredOutputEnabled
297297

298-
if let output = try formatter.format(filteredResults, colored: colored) {
298+
let formattedOutput = try formatter.format(filteredResults, colored: colored)
299+
300+
if let output = formattedOutput {
299301
if outputFormat.supportsAuxiliaryOutput {
300302
logger.info("", canQuiet: true)
301303
}
302304

303305
logger.info(output, canQuiet: false)
306+
}
304307

305-
if !filteredResults.isEmpty, let resultsPath = configuration.writeResults {
306-
var output = output
307-
308-
if colored {
309-
// The formatted output contains ANSI escape codes, so we need to re-format
310-
// with coloring disabled.
311-
output = try formatter.format(filteredResults, colored: false) ?? ""
312-
}
313-
314-
try output.write(to: resultsPath.url, atomically: true, encoding: .utf8)
308+
if let resultsPath = configuration.writeResults {
309+
let output: String = if colored {
310+
// The formatted output contains ANSI escape codes, so we need to re-format
311+
// with coloring disabled.
312+
try formatter.format(filteredResults, colored: false) ?? ""
313+
} else {
314+
formattedOutput ?? ""
315315
}
316+
317+
try output.write(to: resultsPath.url, atomically: true, encoding: .utf8)
316318
}
317319

318320
logger.endInterval(interval)

0 commit comments

Comments
 (0)