chore: try to strip ansi escape characters

This commit is contained in:
DaanSelen
2026-04-01 09:58:31 +02:00
parent 969fc17171
commit 2dc2a8ec99
+10 -4
View File
@@ -4,9 +4,12 @@ import (
"log" "log"
"os" "os"
"os/exec" "os/exec"
"regexp"
"runtime" "runtime"
) )
var ansi = regexp.MustCompile(`\x1b\[[0-9;]*m`)
func FindMeshbookBinary() (bool, string) { func FindMeshbookBinary() (bool, string) {
var osBin string var osBin string
@@ -53,11 +56,14 @@ func RunMeshbook(binPath, bookPath, targGroup string) (bool, string) {
cmd := exec.Command(binPath, args...) cmd := exec.Command(binPath, args...)
outputData, err := cmd.CombinedOutput() outputData, err := cmd.CombinedOutput()
cleanData := ansi.ReplaceAllString(string(outputData), "")
if err != nil { if err != nil {
log.Printf("something went wrong when running the command: %v", err) log.Printf("something went wrong when running the command: %v", err)
log.Printf("captured output: %s", string(outputData)) log.Printf("captured output: %s", cleanData)
return false, string(outputData)
}
return true, string(outputData) return false, cleanData
} else {
return true, cleanData
}
} }