Skip to content

Commit 5e84685

Browse files
committed
perf: remove supports-color dep
1 parent 3c5a889 commit 5e84685

2 files changed

Lines changed: 4 additions & 18 deletions

File tree

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
"peerDependenciesMeta": {
5151
"ms": {
5252
"optional": true
53-
},
54-
"supports-color": {
55-
"optional": true
5653
}
5754
},
5855
"devDependencies": {

src/node.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,16 @@ export function log(...args: any[]): void {
1414
process.stderr.write(`${formatWithOptions(inspectOpts, ...args)}\n`)
1515
}
1616

17-
function getColors() {
18-
try {
19-
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
20-
21-
const supportsColor = require('supports-color')
22-
23-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
24-
return [
17+
export const colors: number[] =
18+
process.stderr.getColorDepth() > 2
19+
? [
2520
20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63,
2621
68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128,
2722
129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168,
2823
169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200,
2924
201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221,
3025
]
31-
}
32-
} catch {
33-
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
34-
}
35-
return [6, 2, 3, 4, 5, 1]
36-
}
37-
export const colors: number[] = getColors()
26+
: [6, 2, 3, 4, 5, 1]
3827

3928
const inspectOpts: InspectOptions = Object.keys(process.env)
4029
.filter((key) => {

0 commit comments

Comments
 (0)