()
| 832 | * @returns {boolean} true when colors supported, otherwise false |
| 833 | */ |
| 834 | const isColorSupported = () => { |
| 835 | const { env = {}, argv = [], platform = "" } = process; |
| 836 | |
| 837 | // Read values instead of using `in`: Deno's and Bun's `process.env` honor |
| 838 | // property access but not the `in`/`has` trap, so `"X" in env` is unreliable. |
| 839 | const isDisabled = env.NO_COLOR !== undefined || argv.includes("--no-color"); |
| 840 | const isForced = env.FORCE_COLOR !== undefined || argv.includes("--color"); |
| 841 | const isWindows = platform === "win32"; |
| 842 | const isDumbTerminal = env.TERM === "dumb"; |
| 843 | |
| 844 | const isCompatibleTerminal = tty.isatty(1) && env.TERM && !isDumbTerminal; |
| 845 | |
| 846 | const isCI = |
| 847 | env.CI !== undefined && |
| 848 | (env.GITHUB_ACTIONS !== undefined || |
| 849 | env.GITLAB_CI !== undefined || |
| 850 | env.CIRCLECI !== undefined); |
| 851 | |
| 852 | return ( |
| 853 | !isDisabled && |
| 854 | (isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI) |
| 855 | ); |
| 856 | }; |
| 857 | |
| 858 | /** |
| 859 | * Returns result. |
no outgoing calls
no test coverage detected