From 79a40f82f5586f29158b55edf4e1d31a1b77569c Mon Sep 17 00:00:00 2001 From: frosty Date: Tue, 20 Aug 2024 23:01:05 +0000 Subject: [PATCH] add some checks for whether exec cmd exits non-0 or output is blank --- lib/readers/exec.go | 5 +++++ main.go | 3 +++ 2 files changed, 8 insertions(+) diff --git a/lib/readers/exec.go b/lib/readers/exec.go index 09e1af9..d30c162 100644 --- a/lib/readers/exec.go +++ b/lib/readers/exec.go @@ -18,6 +18,7 @@ package readers import ( "bytes" + "errors" "os/exec" "strings" ) @@ -36,6 +37,10 @@ func readExec(command string) (interface{}, error) { return ExecInfo(""), err } + if cmd.ProcessState.ExitCode() != 0 { + return ExecInfo(""), errors.New("returned non-zero exit code") + } + outputLines := strings.Split(stdout.String(), "\n") if len(outputLines) == 0 { return ExecInfo(""), nil diff --git a/main.go b/main.go index 51b6d4f..e21c252 100644 --- a/main.go +++ b/main.go @@ -153,6 +153,9 @@ func main() { mutex.Lock() var combinedOutput string for i, output := range moduleOutputs { + if output == "" { + continue + } if i > 0 { combinedOutput += delim }