v4.3.0
Features
- Added
link(url, text?)for OSC 8 hyperlinks, supported by many terminal emulators, #44 - Added constructor overload to pass a mock
globalThisobject for controlled color auto-detection, #47import { Ansis } from 'ansis'; const color = new Ansis({ process: { env: { FORCE_COLOR: '1' }, argv: ['node', 'app.js'], stdout: { isTTY: false }, platform: 'linux', }, }); console.log(color.level); // 1
Bugfix
Fixed the handling edge cases for using ENV variables and CLI flags, #46
| Fixed edge case | Old behavior (bug) | New behavior (correct) |
|---|---|---|
FORCE_COLOR=1, NO_COLOR=1 |
disable color | enable color (FORCE_COLOR takes precedence over NO_COLOR) |
NO_COLOR=1, --color |
disable color | enable color (CLI color flags take precedence over NO_COLOR) |
FORCE_COLOR=1, --no-color |
disable color | enable color (FORCE_COLOR has the highest priority) |
--no-color --color |
disable color | enable color (last flag wins) |
--color with no detected colors |
truecolor | 16 colors (auto-detect fallback uses the minimum color level, not truecolor) |