supports-color 5.5.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +17 -11
- package/package.json +3 -3
- package/readme.md +15 -1
package/index.js
CHANGED
|
@@ -2,21 +2,27 @@
|
|
|
2
2
|
const os = require('os');
|
|
3
3
|
const hasFlag = require('has-flag');
|
|
4
4
|
|
|
5
|
-
const env = process
|
|
5
|
+
const {env} = process;
|
|
6
6
|
|
|
7
7
|
let forceColor;
|
|
8
8
|
if (hasFlag('no-color') ||
|
|
9
9
|
hasFlag('no-colors') ||
|
|
10
10
|
hasFlag('color=false')) {
|
|
11
|
-
forceColor =
|
|
11
|
+
forceColor = 0;
|
|
12
12
|
} else if (hasFlag('color') ||
|
|
13
13
|
hasFlag('colors') ||
|
|
14
14
|
hasFlag('color=true') ||
|
|
15
15
|
hasFlag('color=always')) {
|
|
16
|
-
forceColor =
|
|
16
|
+
forceColor = 1;
|
|
17
17
|
}
|
|
18
18
|
if ('FORCE_COLOR' in env) {
|
|
19
|
-
|
|
19
|
+
if (env.FORCE_COLOR === true || env.FORCE_COLOR === 'true') {
|
|
20
|
+
forceColor = 1;
|
|
21
|
+
} else if (env.FORCE_COLOR === false || env.FORCE_COLOR === 'false') {
|
|
22
|
+
forceColor = 0;
|
|
23
|
+
} else {
|
|
24
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
25
|
+
}
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
function translateLevel(level) {
|
|
@@ -33,7 +39,7 @@ function translateLevel(level) {
|
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
function supportsColor(stream) {
|
|
36
|
-
if (forceColor ===
|
|
42
|
+
if (forceColor === 0) {
|
|
37
43
|
return 0;
|
|
38
44
|
}
|
|
39
45
|
|
|
@@ -47,11 +53,15 @@ function supportsColor(stream) {
|
|
|
47
53
|
return 2;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
if (stream && !stream.isTTY && forceColor
|
|
56
|
+
if (stream && !stream.isTTY && forceColor === undefined) {
|
|
51
57
|
return 0;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
|
-
const min = forceColor
|
|
60
|
+
const min = forceColor || 0;
|
|
61
|
+
|
|
62
|
+
if (env.TERM === 'dumb') {
|
|
63
|
+
return min;
|
|
64
|
+
}
|
|
55
65
|
|
|
56
66
|
if (process.platform === 'win32') {
|
|
57
67
|
// Node.js 7.5.0 is the first version of Node.js to include a patch to
|
|
@@ -112,10 +122,6 @@ function supportsColor(stream) {
|
|
|
112
122
|
return 1;
|
|
113
123
|
}
|
|
114
124
|
|
|
115
|
-
if (env.TERM === 'dumb') {
|
|
116
|
-
return min;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
125
|
return min;
|
|
120
126
|
}
|
|
121
127
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supports-color",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Detect whether a terminal supports color",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/supports-color",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "sindresorhus.com"
|
|
11
11
|
},
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
13
|
+
"node": ">=6"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "xo && ava"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"ava": "^0.25.0",
|
|
49
49
|
"import-fresh": "^2.0.0",
|
|
50
|
-
"xo": "^0.
|
|
50
|
+
"xo": "^0.23.0"
|
|
51
51
|
},
|
|
52
52
|
"browser": "browser.js"
|
|
53
53
|
}
|
package/readme.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
> Detect whether a terminal supports color
|
|
4
4
|
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<b>
|
|
9
|
+
<a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
|
10
|
+
</b>
|
|
11
|
+
<br>
|
|
12
|
+
<sub>
|
|
13
|
+
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
14
|
+
</sub>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
5
19
|
|
|
6
20
|
## Install
|
|
7
21
|
|
|
@@ -44,7 +58,7 @@ The `stdout`/`stderr` objects specifies a level of support for color through a `
|
|
|
44
58
|
|
|
45
59
|
It obeys the `--color` and `--no-color` CLI flags.
|
|
46
60
|
|
|
47
|
-
|
|
61
|
+
For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
|
48
62
|
|
|
49
63
|
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
|
50
64
|
|