supports-color 0.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.
Files changed (4) hide show
  1. package/cli.js +28 -0
  2. package/index.js +32 -0
  3. package/package.json +50 -0
  4. package/readme.md +44 -0
package/cli.js ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ var pkg = require('./package.json');
4
+ var supportsColor = require('./');
5
+ var input = process.argv[2];
6
+
7
+ function help() {
8
+ console.log([
9
+ pkg.description,
10
+ '',
11
+ 'Usage',
12
+ ' $ supports-color',
13
+ '',
14
+ 'Exits with code 0 if color is supported and 1 if not'
15
+ ].join('\n'));
16
+ }
17
+
18
+ if (!input || process.argv.indexOf('--help') !== -1) {
19
+ help();
20
+ return;
21
+ }
22
+
23
+ if (process.argv.indexOf('--version') !== -1) {
24
+ console.log(pkg.version);
25
+ return;
26
+ }
27
+
28
+ process.exit(supportsColor ? 0 : 1);
package/index.js ADDED
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+ module.exports = (function () {
3
+ if (process.argv.indexOf('--no-color') !== -1) {
4
+ return false;
5
+ }
6
+
7
+ if (process.argv.indexOf('--color') !== -1) {
8
+ return true;
9
+ }
10
+
11
+ if (process.stdout && !process.stdout.isTTY) {
12
+ return false;
13
+ }
14
+
15
+ if (process.platform === 'win32') {
16
+ return true;
17
+ }
18
+
19
+ if ('COLORTERM' in process.env) {
20
+ return true;
21
+ }
22
+
23
+ if (process.env.TERM === 'dumb') {
24
+ return false;
25
+ }
26
+
27
+ if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
28
+ return true;
29
+ }
30
+
31
+ return false;
32
+ })();
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "supports-color",
3
+ "version": "0.2.0",
4
+ "description": "Detect whether a terminal supports color",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/supports-color",
7
+ "bin": {
8
+ "supports-color": "cli.js"
9
+ },
10
+ "author": {
11
+ "name": "Sindre Sorhus",
12
+ "email": "sindresorhus@gmail.com",
13
+ "url": "http://sindresorhus.com"
14
+ },
15
+ "engines": {
16
+ "node": ">=0.10.0"
17
+ },
18
+ "scripts": {
19
+ "test": "mocha"
20
+ },
21
+ "files": [
22
+ "index.js",
23
+ "cli.js"
24
+ ],
25
+ "keywords": [
26
+ "cli",
27
+ "bin",
28
+ "color",
29
+ "colour",
30
+ "colors",
31
+ "terminal",
32
+ "console",
33
+ "cli",
34
+ "ansi",
35
+ "styles",
36
+ "tty",
37
+ "rgb",
38
+ "256",
39
+ "shell",
40
+ "xterm",
41
+ "command-line",
42
+ "support",
43
+ "supports",
44
+ "capability",
45
+ "detect"
46
+ ],
47
+ "devDependencies": {
48
+ "mocha": "*"
49
+ }
50
+ }
package/readme.md ADDED
@@ -0,0 +1,44 @@
1
+ # supports-color [![Build Status](https://travis-ci.org/sindresorhus/supports-color.svg?branch=master)](https://travis-ci.org/sindresorhus/supports-color)
2
+
3
+ > Detect whether a terminal supports color
4
+
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ $ npm install --save supports-color
10
+ ```
11
+
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ var supportsColor = require('supports-color');
17
+
18
+ if (supportsColor) {
19
+ console.log('Terminal supports color');
20
+ }
21
+ ```
22
+
23
+ It obeys the `--color` and `--no-color` CLI flags.
24
+
25
+
26
+ ## CLI
27
+
28
+ ```sh
29
+ $ npm install --global supports-color
30
+ ```
31
+
32
+ ```sh
33
+ $ supports-color --help
34
+
35
+ Usage
36
+ $ supports-color
37
+
38
+ # Exits with code 0 if color is supported and 1 if not
39
+ ```
40
+
41
+
42
+ ## License
43
+
44
+ MIT © [Sindre Sorhus](http://sindresorhus.com)