From 394fb1ab640ecd196e715fb086caf69f5ac2bfd1 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 28 Jan 2022 15:12:13 +0100 Subject: [PATCH] Don't run OSC queries on CI --- termenv.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/termenv.go b/termenv.go index 4677856..2861e38 100644 --- a/termenv.go +++ b/termenv.go @@ -22,10 +22,18 @@ const ( TrueColor ) +func isTTY(fd uintptr) bool { + if len(os.Getenv("CI")) > 0 { + return false + } + + return isatty.IsTerminal(fd) +} + // ColorProfile returns the supported color profile: // Ascii, ANSI, ANSI256, or TrueColor. func ColorProfile() Profile { - if !isatty.IsTerminal(os.Stdout.Fd()) { + if !isTTY(os.Stdout.Fd()) { return Ascii } @@ -34,7 +42,7 @@ func ColorProfile() Profile { // ForegroundColor returns the terminal's default foreground color. func ForegroundColor() Color { - if !isatty.IsTerminal(os.Stdout.Fd()) { + if !isTTY(os.Stdout.Fd()) { return NoColor{} } @@ -43,7 +51,7 @@ func ForegroundColor() Color { // BackgroundColor returns the terminal's default background color. func BackgroundColor() Color { - if !isatty.IsTerminal(os.Stdout.Fd()) { + if !isTTY(os.Stdout.Fd()) { return NoColor{} }