mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 18:18:57 +01:00
fix(color): Deno does not require permission for NO_COLOR
(#3306)
This commit is contained in:
parent
6d7565e2a1
commit
0a94e53832
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user