From d059cfa7d6f005bf03228a30a53bc8c492a5c3ee Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 13 May 2024 16:55:13 -0400 Subject: [PATCH] fix: DetectColorProfile takes a writer --- env.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/env.go b/env.go index 6d419278..ab5a4168 100644 --- a/env.go +++ b/env.go @@ -1,6 +1,8 @@ package lipgloss import ( + "io" + "log" "os" "strconv" "strings" @@ -17,14 +19,14 @@ import ( // CLICOLOR/CLICOLOR_FORCE environment variables. // // See https://no-color.org/ and https://bixense.com/clicolors/ for more information. -func DetectColorProfile(stdout term.File, environ []string) Profile { +func DetectColorProfile(output io.Writer, environ []string) Profile { if environ == nil { environ = os.Environ() } env := environMap(environ) p := envColorProfile(env) - if stdout == nil || !term.IsTerminal(stdout.Fd()) { + if out, ok := output.(term.File); !ok || !term.IsTerminal(out.Fd()) { p = NoTTY } @@ -117,6 +119,7 @@ func envColorProfile(env map[string]string) (p Profile) { p = Ascii // Default to ASCII setProfile := func(profile Profile) { if profile < p { + log.Output(3, "Setting profile to "+profile.String()) p = profile } }