supports-color 6.0.0 → 7.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 +14 -16
- package/package.json +6 -6
- package/readme.md +12 -16
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const os = require('os');
|
|
3
|
+
const tty = require('tty');
|
|
3
4
|
const hasFlag = require('has-flag');
|
|
4
5
|
|
|
5
6
|
const {env} = process;
|
|
@@ -7,7 +8,8 @@ const {env} = process;
|
|
|
7
8
|
let forceColor;
|
|
8
9
|
if (hasFlag('no-color') ||
|
|
9
10
|
hasFlag('no-colors') ||
|
|
10
|
-
hasFlag('color=false')
|
|
11
|
+
hasFlag('color=false') ||
|
|
12
|
+
hasFlag('color=never')) {
|
|
11
13
|
forceColor = 0;
|
|
12
14
|
} else if (hasFlag('color') ||
|
|
13
15
|
hasFlag('colors') ||
|
|
@@ -15,10 +17,11 @@ if (hasFlag('no-color') ||
|
|
|
15
17
|
hasFlag('color=always')) {
|
|
16
18
|
forceColor = 1;
|
|
17
19
|
}
|
|
20
|
+
|
|
18
21
|
if ('FORCE_COLOR' in env) {
|
|
19
|
-
if (env.FORCE_COLOR ===
|
|
22
|
+
if (env.FORCE_COLOR === 'true') {
|
|
20
23
|
forceColor = 1;
|
|
21
|
-
} else if (env.FORCE_COLOR ===
|
|
24
|
+
} else if (env.FORCE_COLOR === 'false') {
|
|
22
25
|
forceColor = 0;
|
|
23
26
|
} else {
|
|
24
27
|
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
@@ -38,7 +41,7 @@ function translateLevel(level) {
|
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
function supportsColor(
|
|
44
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
42
45
|
if (forceColor === 0) {
|
|
43
46
|
return 0;
|
|
44
47
|
}
|
|
@@ -53,7 +56,7 @@ function supportsColor(stream) {
|
|
|
53
56
|
return 2;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
if (
|
|
59
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
57
60
|
return 0;
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -64,15 +67,10 @@ function supportsColor(stream) {
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
if (process.platform === 'win32') {
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
|
|
70
|
-
// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
|
|
71
|
-
// release that supports 256 colors. Windows 10 build 14931 is the first release
|
|
72
|
-
// that supports 16m/TrueColor.
|
|
70
|
+
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
71
|
+
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
73
72
|
const osRelease = os.release().split('.');
|
|
74
73
|
if (
|
|
75
|
-
Number(process.versions.node.split('.')[0]) >= 8 &&
|
|
76
74
|
Number(osRelease[0]) >= 10 &&
|
|
77
75
|
Number(osRelease[2]) >= 10586
|
|
78
76
|
) {
|
|
@@ -83,7 +81,7 @@ function supportsColor(stream) {
|
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
if ('CI' in env) {
|
|
86
|
-
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
84
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
87
85
|
return 1;
|
|
88
86
|
}
|
|
89
87
|
|
|
@@ -126,12 +124,12 @@ function supportsColor(stream) {
|
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
function getSupportLevel(stream) {
|
|
129
|
-
const level = supportsColor(stream);
|
|
127
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
130
128
|
return translateLevel(level);
|
|
131
129
|
}
|
|
132
130
|
|
|
133
131
|
module.exports = {
|
|
134
132
|
supportsColor: getSupportLevel,
|
|
135
|
-
stdout:
|
|
136
|
-
stderr:
|
|
133
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
134
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
137
135
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supports-color",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.2.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": ">=8"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "xo && ava"
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"16m"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"has-flag": "^
|
|
45
|
+
"has-flag": "^4.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"ava": "^
|
|
49
|
-
"import-fresh": "^
|
|
50
|
-
"xo": "^0.
|
|
48
|
+
"ava": "^1.4.1",
|
|
49
|
+
"import-fresh": "^3.0.0",
|
|
50
|
+
"xo": "^0.24.0"
|
|
51
51
|
},
|
|
52
52
|
"browser": "browser.js"
|
|
53
53
|
}
|
package/readme.md
CHANGED
|
@@ -2,20 +2,6 @@
|
|
|
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
|
-
|
|
19
5
|
|
|
20
6
|
## Install
|
|
21
7
|
|
|
@@ -75,6 +61,16 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
|
|
75
61
|
- [Josh Junon](https://github.com/qix-)
|
|
76
62
|
|
|
77
63
|
|
|
78
|
-
|
|
64
|
+
---
|
|
79
65
|
|
|
80
|
-
|
|
66
|
+
<div align="center">
|
|
67
|
+
<b>
|
|
68
|
+
<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>
|
|
69
|
+
</b>
|
|
70
|
+
<br>
|
|
71
|
+
<sub>
|
|
72
|
+
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
73
|
+
</sub>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
---
|