Sha256: e7f0073a204d83f8cec4edc08dbe74929ba7f5fe6c98f36972289898eaae327c

Contents?: true

Size: 1.82 KB

Versions: 200

Compression:

Stored size: 1.82 KB

Contents

# supports-color [![Build Status](https://travis-ci.org/chalk/supports-color.svg?branch=master)](https://travis-ci.org/chalk/supports-color)

> Detect whether a terminal supports color


## Install

```
$ npm install supports-color
```


## Usage

```js
const supportsColor = require('supports-color');

if (supportsColor.stdout) {
	console.log('Terminal stdout supports color');
}

if (supportsColor.stdout.has256) {
	console.log('Terminal stdout supports 256 colors');
}

if (supportsColor.stderr.has16m) {
	console.log('Terminal stderr supports 16 million colors (truecolor)');
}
```


## API

Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.

The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:

- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
- `.level = 2` and `.has256 = true`: 256 color support
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)


## Info

It obeys the `--color` and `--no-color` CLI flags.

Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add the environment variable `FORCE_COLOR=1` to forcefully enable color or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.

Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.


## Related

- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right


## Maintainers

- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)


## License

MIT

Version data entries

200 entries across 167 versions & 21 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.59 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.58 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.57 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.56 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.55 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.54 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.53 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.52 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
trusty-cms-6.3.1 node_modules/supports-color/readme.md
immosquare-cleaner-0.1.51 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
clapton-0.0.26 lib/clapton/javascripts/node_modules/@babel/highlight/node_modules/supports-color/readme.md
clapton-0.0.25 lib/clapton/javascripts/node_modules/@babel/highlight/node_modules/supports-color/readme.md
immosquare-cleaner-0.1.50 node_modules/@babel/highlight/node_modules/chalk/node_modules/supports-color/readme.md
clapton-0.0.24 lib/clapton/javascripts/node_modules/@babel/highlight/node_modules/supports-color/readme.md
clapton-0.0.23 lib/clapton/javascripts/node_modules/@babel/highlight/node_modules/supports-color/readme.md
clapton-0.0.22 lib/clapton/javascripts/node_modules/@babel/highlight/node_modules/supports-color/readme.md
clapton-0.0.21 lib/clapton/javascripts/node_modules/@babel/highlight/node_modules/supports-color/readme.md
clapton-0.0.20 lib/clapton/javascripts/node_modules/@babel/highlight/node_modules/supports-color/readme.md
clapton-0.0.19 lib/clapton/javascripts/node_modules/@babel/highlight/node_modules/supports-color/readme.md