Skip to content

Commit

Permalink
fix: support Vercel Edge Runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Apr 29, 2023
1 parent 6b43e8e commit 387eae4
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions picocolors.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
let tty = require("tty")
const isColorSupported = (() => {
const argv = process.argv || []

let isColorSupported =
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
("FORCE_COLOR" in process.env ||
process.argv.includes("--color") ||
if ("NO_COLOR" in process.env || argv.includes("--no-color")) {
return false
}

if (
"FORCE_COLOR" in process.env ||
argv.includes("--color") ||
process.platform === "win32" ||
(tty.isatty(1) && process.env.TERM !== "dumb") ||
"CI" in process.env)
"CI" in process.env
) {
return true
}

{
let tty
try {
const req = require
tty = req("tty")
} catch {
return false
}
return tty.isatty(1) && process.env.TERM !== "dumb"
}
})()

let formatter =
(open, close, replace = open) =>
Expand Down

0 comments on commit 387eae4

Please sign in to comment.