mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
This commit fixes the ANSI color detection logic in `Output.enable_ansi_colors_stdout` and `Output.enable_ansi_colors_stderr` to ensure colors are disabled when output is redirected to a file or unix pipe, unless `FORCE_COLOR` is explicitly set. The previous implementation had a subtle bug: when `isColorTerminal()` returned true AND either stdout OR stderr was a TTY, it would set `enable_color = true`. This caused both stdout and stderr to have colors enabled, even if one of them was redirected to a pipe or file. The new implementation: 1. `FORCE_COLOR` environment variable - always enables colors 2. `NO_COLOR` environment variable - always disables colors 3. Color terminal detection - enables colors only for the specific stream that is a TTY 4. Default - disables colors for files and pipes (non-TTY) Added comprehensive tests to verify the behavior across different scenarios including syntax errors, runtime errors, test output, and install output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>