supports-color 1.3.1 → 2.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 +14 -7
- package/package.json +3 -9
- package/readme.md +4 -14
- package/cli.js +0 -29
package/index.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var argv = process.argv;
|
|
3
3
|
|
|
4
|
+
var terminator = argv.indexOf('--');
|
|
5
|
+
var hasFlag = function (flag) {
|
|
6
|
+
flag = '--' + flag;
|
|
7
|
+
var pos = argv.indexOf(flag);
|
|
8
|
+
return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
|
|
9
|
+
};
|
|
10
|
+
|
|
4
11
|
module.exports = (function () {
|
|
5
12
|
if ('FORCE_COLOR' in process.env) {
|
|
6
13
|
return true;
|
|
7
14
|
}
|
|
8
15
|
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
if (hasFlag('no-color') ||
|
|
17
|
+
hasFlag('no-colors') ||
|
|
18
|
+
hasFlag('color=false')) {
|
|
12
19
|
return false;
|
|
13
20
|
}
|
|
14
21
|
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
if (hasFlag('color') ||
|
|
23
|
+
hasFlag('colors') ||
|
|
24
|
+
hasFlag('color=true') ||
|
|
25
|
+
hasFlag('color=always')) {
|
|
19
26
|
return true;
|
|
20
27
|
}
|
|
21
28
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supports-color",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Detect whether a terminal supports color",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"repository": "
|
|
6
|
+
"repository": "chalk/supports-color",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Sindre Sorhus",
|
|
9
9
|
"email": "sindresorhus@gmail.com",
|
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
"Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
|
|
14
14
|
"Joshua Appelman <jappelman@xebia.com> (jbnicolai.com)"
|
|
15
15
|
],
|
|
16
|
-
"bin": {
|
|
17
|
-
"supports-color": "cli.js"
|
|
18
|
-
},
|
|
19
16
|
"engines": {
|
|
20
17
|
"node": ">=0.8.0"
|
|
21
18
|
},
|
|
@@ -23,12 +20,9 @@
|
|
|
23
20
|
"test": "mocha"
|
|
24
21
|
},
|
|
25
22
|
"files": [
|
|
26
|
-
"index.js"
|
|
27
|
-
"cli.js"
|
|
23
|
+
"index.js"
|
|
28
24
|
],
|
|
29
25
|
"keywords": [
|
|
30
|
-
"cli",
|
|
31
|
-
"bin",
|
|
32
26
|
"color",
|
|
33
27
|
"colour",
|
|
34
28
|
"colors",
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# supports-color [](https://travis-ci.org/chalk/supports-color)
|
|
2
2
|
|
|
3
3
|
> Detect whether a terminal supports color
|
|
4
4
|
|
|
@@ -25,20 +25,10 @@ It obeys the `--color` and `--no-color` CLI flags.
|
|
|
25
25
|
For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Related
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
$ supports-color --help
|
|
36
|
-
|
|
37
|
-
Usage
|
|
38
|
-
supports-color
|
|
39
|
-
|
|
40
|
-
Exits with code 0 if color is supported and 1 if not
|
|
41
|
-
```
|
|
30
|
+
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
|
|
31
|
+
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
|
42
32
|
|
|
43
33
|
|
|
44
34
|
## License
|
package/cli.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
var pkg = require('./package.json');
|
|
4
|
-
var supportsColor = require('./');
|
|
5
|
-
var argv = process.argv.slice(2);
|
|
6
|
-
|
|
7
|
-
function help() {
|
|
8
|
-
console.log([
|
|
9
|
-
'',
|
|
10
|
-
' ' + pkg.description,
|
|
11
|
-
'',
|
|
12
|
-
' Usage',
|
|
13
|
-
' supports-color',
|
|
14
|
-
'',
|
|
15
|
-
' Exits with code 0 if color is supported and 1 if not'
|
|
16
|
-
].join('\n'));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (argv.indexOf('--help') !== -1) {
|
|
20
|
-
help();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (argv.indexOf('--version') !== -1) {
|
|
25
|
-
console.log(pkg.version);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
process.exit(supportsColor ? 0 : 1);
|