supports-color 5.1.0 → 5.2.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 +23 -20
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -4,6 +4,21 @@ const hasFlag = require('has-flag');
|
|
|
4
4
|
|
|
5
5
|
const env = process.env;
|
|
6
6
|
|
|
7
|
+
let forceColor;
|
|
8
|
+
if (hasFlag('no-color') ||
|
|
9
|
+
hasFlag('no-colors') ||
|
|
10
|
+
hasFlag('color=false')) {
|
|
11
|
+
forceColor = false;
|
|
12
|
+
} else if (hasFlag('color') ||
|
|
13
|
+
hasFlag('colors') ||
|
|
14
|
+
hasFlag('color=true') ||
|
|
15
|
+
hasFlag('color=always')) {
|
|
16
|
+
forceColor = true;
|
|
17
|
+
}
|
|
18
|
+
if ('FORCE_COLOR' in env) {
|
|
19
|
+
forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
function translateLevel(level) {
|
|
8
23
|
if (level === 0) {
|
|
9
24
|
return false;
|
|
@@ -18,9 +33,7 @@ function translateLevel(level) {
|
|
|
18
33
|
}
|
|
19
34
|
|
|
20
35
|
function supportsColor(stream) {
|
|
21
|
-
if (
|
|
22
|
-
hasFlag('no-colors') ||
|
|
23
|
-
hasFlag('color=false')) {
|
|
36
|
+
if (forceColor === false) {
|
|
24
37
|
return 0;
|
|
25
38
|
}
|
|
26
39
|
|
|
@@ -34,17 +47,12 @@ function supportsColor(stream) {
|
|
|
34
47
|
return 2;
|
|
35
48
|
}
|
|
36
49
|
|
|
37
|
-
if (
|
|
38
|
-
hasFlag('colors') ||
|
|
39
|
-
hasFlag('color=true') ||
|
|
40
|
-
hasFlag('color=always')) {
|
|
41
|
-
return 1;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (stream && !stream.isTTY) {
|
|
50
|
+
if (stream && !stream.isTTY && forceColor !== true) {
|
|
45
51
|
return 0;
|
|
46
52
|
}
|
|
47
53
|
|
|
54
|
+
const min = forceColor ? 1 : 0;
|
|
55
|
+
|
|
48
56
|
if (process.platform === 'win32') {
|
|
49
57
|
// Node.js 7.5.0 is the first version of Node.js to include a patch to
|
|
50
58
|
// libuv that enables 256 color output on Windows. Anything earlier and it
|
|
@@ -69,7 +77,7 @@ function supportsColor(stream) {
|
|
|
69
77
|
return 1;
|
|
70
78
|
}
|
|
71
79
|
|
|
72
|
-
return
|
|
80
|
+
return min;
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
if ('TEAMCITY_VERSION' in env) {
|
|
@@ -103,19 +111,14 @@ function supportsColor(stream) {
|
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
if (env.TERM === 'dumb') {
|
|
106
|
-
return
|
|
114
|
+
return min;
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
return
|
|
117
|
+
return min;
|
|
110
118
|
}
|
|
111
119
|
|
|
112
120
|
function getSupportLevel(stream) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if ('FORCE_COLOR' in env) {
|
|
116
|
-
level = (env.FORCE_COLOR.length > 0 && parseInt(env.FORCE_COLOR, 10) === 0) ? 0 : (level || 1);
|
|
117
|
-
}
|
|
118
|
-
|
|
121
|
+
const level = supportsColor(stream);
|
|
119
122
|
return translateLevel(level);
|
|
120
123
|
}
|
|
121
124
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supports-color",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Detect whether a terminal supports color",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/supports-color",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"16m"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"has-flag": "^
|
|
45
|
+
"has-flag": "^3.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"ava": "*",
|