MCPcopy
hub / github.com/webpack/webpack / isColorSupported

Function isColorSupported

lib/cli.js:834–856  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

832 * @returns {boolean} true when colors supported, otherwise false
833 */
834const 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.

Callers 2

createColorsFunction · 0.85
Cli.basictest.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected