Commit 1a189ef2 authored by Kim, Hyeonseo's avatar Kim, Hyeonseo
Browse files

fix: enhance color support detection by checking NO_COLOR first

parent 4e2ae2cb
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -259,10 +259,14 @@ export const Jimp = createJimp({
});

function checkTerminalColorSupport(): "truecolor" | "256color" | "none" {
  const colorTerm = Deno.env.get("COLORTERM");
  const term = Deno.env.get("TERM");
  // Check if colors are explicitly disabled
  const noColor = Deno.env.get("NO_COLOR");
  if (noColor != null && noColor !== "") {
    return "none";
  }

  // Check for true color (24-bit) support
  const colorTerm = Deno.env.get("COLORTERM");
  if (
    colorTerm != null &&
    (colorTerm.includes("24bit") || colorTerm.includes("truecolor"))
@@ -271,6 +275,7 @@ function checkTerminalColorSupport(): "truecolor" | "256color" | "none" {
  }

  // Check for xterm 256-color support
  const term = Deno.env.get("TERM");
  if (
    term != null &&
    (term.includes("256color") ||
@@ -281,12 +286,6 @@ function checkTerminalColorSupport(): "truecolor" | "256color" | "none" {
    return "256color";
  }

  // Check if colors are explicitly disabled
  const noColor = Deno.env.get("NO_COLOR");
  if (noColor != null && noColor !== "") {
    return "none";
  }

  // Fallback: assume basic color support if TERM is set
  if (term != null && term !== "dumb") {
    return "256color";