|
1 | 1 | /** |
2 | 2 | * Color utilities for CLI help output with NO_COLOR environment variable support. |
3 | 3 | * |
4 | | - * This module provides ANSI color codes for terminal output while respecting |
5 | | - * the NO_COLOR environment variable standard (https://no-color.org/). |
| 4 | + * This module provides ANSI color codes for terminal output. |
6 | 5 | * |
7 | 6 | * Features: |
8 | | - * - Automatic color detection based on environment |
9 | | - * - NO_COLOR environment variable support |
10 | | - * - Graceful fallback to plain text |
| 7 | + * - Simple boolean-based color control |
| 8 | + * - No automatic detection or environment checks |
| 9 | + * - Users can implement their own color detection logic |
11 | 10 | * - Common color functions for CLI output |
12 | 11 | */ |
13 | 12 |
|
@@ -50,37 +49,14 @@ const COLORS = { |
50 | 49 | /** |
51 | 50 | * Determines if color output should be enabled. |
52 | 51 | * |
53 | | - * Colors are disabled if: |
54 | | - * - NO_COLOR environment variable is set (any value) |
55 | | - * - Terminal doesn't support colors |
56 | | - * - Color is explicitly disabled |
| 52 | + * Simply returns the enableColor value - no heuristics or environment checks. |
| 53 | + * Users can wrap their CLI with their own color detection logic if needed. |
57 | 54 | * |
58 | 55 | * @param enableColor - Explicit color preference |
59 | 56 | * @returns true if colors should be used |
60 | 57 | */ |
61 | 58 | function shouldUseColors(enableColor?: boolean): boolean { |
62 | | - // Explicit disable takes precedence |
63 | | - if (enableColor === false) { |
64 | | - return false; |
65 | | - } |
66 | | - |
67 | | - // Check NO_COLOR environment variable |
68 | | - if (process.env.NO_COLOR !== undefined) { |
69 | | - return false; |
70 | | - } |
71 | | - |
72 | | - // Check if stdout is a TTY |
73 | | - if (!process.stdout.isTTY) { |
74 | | - return false; |
75 | | - } |
76 | | - |
77 | | - // If explicitly enabled, use colors |
78 | | - if (enableColor === true) { |
79 | | - return true; |
80 | | - } |
81 | | - |
82 | | - // Default: auto-detect based on environment |
83 | | - return process.stdout.isTTY && !process.env.NO_COLOR; |
| 59 | + return enableColor === true; |
84 | 60 | } |
85 | 61 |
|
86 | 62 | /** |
@@ -155,6 +131,6 @@ export function createColors(enableColor?: boolean): { |
155 | 131 | } |
156 | 132 |
|
157 | 133 | /** |
158 | | - * Default color instance for convenience. |
| 134 | + * Default color instance for convenience (colors disabled by default). |
159 | 135 | */ |
160 | 136 | export const colors = createColors(); |
0 commit comments