Ansis checks COLORTERM before TERM=dumb, so a dumb terminal that inherited COLORTERM=truecolor from its parent gets truecolor output.
Current Behavior
With TERM=dumb and COLORTERM=truecolor on a TTY, ansis.level is 3. The COLORTERM lookup at color-support.js:46-54 returns before the TERM=dumb check at line 74. The README documents this order, but it emits escape sequences into a terminal that reports it cannot render them.
This happens in Emacs: M-x shell and M-x compile set TERM=dumb (comint-terminfo-terminal), and Emacs launched from a terminal that sets COLORTERM=truecolor inherits it. Node's tty.WriteStream#getColorDepth and supports-color report no color in this environment.
Expected Behavior
ansis.level is 0 when TERM=dumb, regardless of COLORTERM.
Reproduction
npm i ansis@4.3.1
cat > repro.mjs <<'JS'
import ansis from 'ansis'
console.log(process.stdout.isTTY, ansis.level, JSON.stringify(ansis.red('x')))
JS
# `script` allocates a pty so stdout.isTTY is true
TERM=dumb COLORTERM=truecolor script -q /dev/null node repro.mjs
Output:
true 3 "\u001b[31mx\u001b[39m"
Unsetting COLORTERM produces true 0 "x".
Environment
- OS: macOS 14.6.1
- Node.js: v26.7.0
- Package version: 4.3.1
Additional Context
Testing term === 'dumb' before the COLORTERM lookup, with !isTTY() left where it is, keeps COLORTERM working for non-TTY output.
Ansis checks
COLORTERMbeforeTERM=dumb, so a dumb terminal that inheritedCOLORTERM=truecolorfrom its parent gets truecolor output.Current Behavior
With
TERM=dumbandCOLORTERM=truecoloron a TTY,ansis.levelis 3. TheCOLORTERMlookup atcolor-support.js:46-54returns before theTERM=dumbcheck at line 74. The README documents this order, but it emits escape sequences into a terminal that reports it cannot render them.This happens in Emacs:
M-x shellandM-x compilesetTERM=dumb(comint-terminfo-terminal), and Emacs launched from a terminal that setsCOLORTERM=truecolorinherits it. Node'stty.WriteStream#getColorDepthandsupports-colorreport no color in this environment.Expected Behavior
ansis.levelis 0 whenTERM=dumb, regardless ofCOLORTERM.Reproduction
Output:
Unsetting
COLORTERMproducestrue 0 "x".Environment
Additional Context
Testing
term === 'dumb'before theCOLORTERMlookup, with!isTTY()left where it is, keepsCOLORTERMworking for non-TTY output.