Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Allow graceful handling of no sarif files #62

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/main/kotlin/slack/cli/sarif/MergeSarifReports.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public class MergeSarifReports :
)
.flag()

private val allowEmpty by
option(
"--allow-empty",
help = "Flag to allow graceful exiting if no sarif files are found.",
envvar = "SARIF_MERGING_ALLOW_EMPTY"
)
.flag()

private fun log(message: String) {
if (verbose) {
echo(message)
Expand Down Expand Up @@ -311,8 +319,13 @@ public class MergeSarifReports :
override fun run() {
val sarifFiles = findSarifFiles()
if (sarifFiles.isEmpty()) {
log("No sarif files found! Did you run lint/detekt first?")
exitProcess(1)
if (allowEmpty) {
println("No sarif files found, skipping merging")
exitProcess(0)
} else {
System.err.println("No sarif files found! Did you run lint/detekt first?")
exitProcess(1)
}
}
merge(sarifFiles)
}
Expand Down