mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2025-12-12 02:00:18 +01:00
fix: handle final newline in messages correctly
This commit is contained in:
parent
c1ad61b367
commit
5436abf377
1 changed files with 5 additions and 0 deletions
|
|
@ -27,11 +27,13 @@ func printErrors(results Results) {
|
|||
message = fmt.Sprintf("Diff:\n%s", dmp.DiffPrettyText(diffs))
|
||||
}
|
||||
|
||||
endedWithNewline := false
|
||||
// handle multi-line colored changes
|
||||
colorState := ""
|
||||
colorRegex := regexp.MustCompile(`\x1b\[[0-9;]*m`) // Match any escape sequence
|
||||
for line := range strings.Lines(message) {
|
||||
coloredLine := colorState + line
|
||||
endedWithNewline = strings.HasSuffix(coloredLine, "\n")
|
||||
fmt.Printf("%s %s", text.FgRed.Sprint("|"), coloredLine)
|
||||
|
||||
matches := colorRegex.FindAllString(line, -1)
|
||||
|
|
@ -46,6 +48,9 @@ func printErrors(results Results) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if endedWithNewline {
|
||||
fmt.Printf("%s", text.FgRed.Sprint("|"))
|
||||
}
|
||||
if message == "" {
|
||||
fmt.Printf("- no output -")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue