From c2ab870c7eb6bbfc9551ef414bb875ad7206b40c Mon Sep 17 00:00:00 2001 From: Michael Fridman Date: Sun, 10 Jul 2022 08:58:27 -0400 Subject: [PATCH] Set explicit true color profile --- internal/app/console_writer.go | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/internal/app/console_writer.go b/internal/app/console_writer.go index ddd392a..f55e090 100644 --- a/internal/app/console_writer.go +++ b/internal/app/console_writer.go @@ -2,8 +2,6 @@ package app import ( "io" - "os" - "strconv" "github.com/charmbracelet/lipgloss" "github.com/muesli/termenv" @@ -62,18 +60,14 @@ func newConsoleWriter(w io.Writer, format OutputFormat, disableColor bool) *cons cw.yellow = noColor() if !disableColor { - // NOTE(mf): The GitHub Actions CI env (and probably others) does not have an - // interactive TTY, and tparse will degrade to the "best available option" .. - // which is no colors. We can work around this by setting the color profile - // manually instead of relying on it to auto-detect. + // NOTE(mf): GitHub Actions CI env (and probably others) do not have an + // interactive TTY, and tparse through termenv will degrade to the + // "best available option" .. which is no colors. We can work around this by + // setting a color profile explicitly instead of relying on termenv to auto-detect. // Ref: https://github.com/charmbracelet/lipgloss/issues/74 - // - // TODO(mf): Should this be an explicit env variable instead? Such as TPARSE_FORCE_COLOR - // - // For now we best-effort the most common CI environments and set this manually. - if isCIEnvironment() { - lipgloss.SetColorProfile(termenv.TrueColor) - } + // Ref: https://github.com/mfridman/tparse/issues/76 + lipgloss.SetColorProfile(termenv.TrueColor) + switch format { case OutputFormatMarkdown: cw.green = newMarkdownColor("🟢") @@ -87,12 +81,3 @@ func newConsoleWriter(w io.Writer, format OutputFormat, disableColor bool) *cons } return cw } - -func isCIEnvironment() bool { - if s := os.Getenv("CI"); s != "" { - if ok, err := strconv.ParseBool(s); err == nil && ok { - return true - } - } - return false -}