diff --git a/src/utils/color.ts b/src/utils/color.ts index cc9fe7a2..7e6d7b8b 100644 --- a/src/utils/color.ts +++ b/src/utils/color.ts @@ -3,16 +3,23 @@ * Color utility. */ +/** + * Get whether color change on terminal is enabled or disabled. + * If `NO_COLOR` environment variable is set, this function returns `false`. + * @see {@link https://no-color.org/} + * + * @returns {boolean} + */ export function getColorEnabled(): boolean { // eslint-disable-next-line @typescript-eslint/no-explicit-any const { process, Deno } = globalThis as any const isNoColor = - typeof process !== 'undefined' + typeof Deno?.noColor === 'boolean' + ? (Deno.noColor as boolean) + : typeof process !== 'undefined' ? // eslint-disable-next-line no-unsafe-optional-chaining 'NO_COLOR' in process?.env - : typeof Deno?.noColor === 'boolean' - ? (Deno.noColor as boolean) : false return !isNoColor