Skip to content

Commit

Permalink
Destructure process into constants (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgebucaran committed Jun 14, 2022
1 parent e83603a commit 0ec9599
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import * as tty from "tty"

const proc = typeof process === "undefined" ? {} : process

const env = proc.env || {}
const argv = proc.argv || []
const { env, argv, platform } = typeof process === "undefined" ? {} : process

const isDisabled = "NO_COLOR" in env || argv.includes("--no-color")
const isForced = "FORCE_COLOR" in env || argv.includes("--color")
const isWindows = proc.platform === "win32"
const isWindows = platform === "win32"
const isDumbTerminal = env.TERM === "dumb"

const isCompatibleTerminal =
Expand All @@ -18,7 +15,8 @@ const isCI =
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env)

export const isColorSupported =
!isDisabled && (isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI)
!isDisabled &&
(isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI)

const replaceClose = (
index,
Expand Down

0 comments on commit 0ec9599

Please sign in to comment.