import isUnicodeSupported from 'is-unicode-supported'; /** * Whether the current process should emit Unicode/emoji in console output. * * Uses `is-unicode-supported` (a transitive dep of ora) which returns `true` * everywhere except legacy Windows terminals (cmd.exe, older PowerShell hosts). * Additionally gates on `process.stdout.isTTY` so that piped output — including * most CI log collectors — falls back to ASCII. This keeps log parsers stable * and avoids surrogate-pair noise in captured logs. * * Override by setting ROOT_CLI_FORCE_UNICODE=1 (force emoji) or * ROOT_CLI_FORCE_ASCII=1 (force plain text) for diagnosing output issues. * * NOTE: This value is captured at module load and does not re-evaluate if stdout * is later piped/wrapped. The contract is that environment overrides must be set * before the CLI starts. If a test harness needs a different value it should set * ROOT_CLI_FORCE_{UNICODE,ASCII} in its process env before requiring this module. */ export const useUnicode: boolean = (() => { if (process.env.ROOT_CLI_FORCE_UNICODE === '1') return true; if (process.env.ROOT_CLI_FORCE_ASCII === '1') return false; return isUnicodeSupported() && process.stdout.isTTY === true; })(); /** * Console symbols for user-facing output. Use these instead of inlining emoji * so Windows/CI environments get ASCII fallbacks automatically. */ export const symbols = { info: useUnicode ? 'ℹ️ ' : '[i] ', check: useUnicode ? '☑️ ' : '[ok] ', success: useUnicode ? '✓ ' : '[ok] ', warning: useUnicode ? '⚠️ ' : '[!] ', error: useUnicode ? '❌ ' : '[err] ', disabled: useUnicode ? '🟠 ' : '[!] ', unknown: useUnicode ? '? ' : '[?] ', pointer: useUnicode ? '▶ ' : '> ', arrow: useUnicode ? '→ ' : '-> ', retry: useUnicode ? '↻ ' : '~ ', edit: useUnicode ? '✎ ' : '* ', branch: useUnicode ? '↳ ' : '`- ', };