mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(app): pretty-print JSON on a terminal and reconcile the foundation streams
writeJSON uses the indented, colored JSON writer when stdout is a terminal. Help and JSON tests now expect the -L shorthand column and compare terminal JSON without color sequences. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
4 files changed
+17
-8
No files matched your search
@@ -15,6 +15,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -291,3 +292,10 @@ func selectablesHandler(t *testing.T, push bool, next http.HandlerFunc) http.Han
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ansiSequence = regexp.MustCompile("\x1b\\[[0-9;]*m")
|
||||
|
||||
// withoutANSI drops SGR color sequences, such as those in pretty JSON on a terminal.
|
||||
func withoutANSI(s string) string {
|
||||
return ansiSequence.ReplaceAllString(s, "")
|
||||
}
|
||||
Reference in new issue
Block a user