{"id":13493792,"url":"https://github.com/chalk/supports-color","last_synced_at":"2025-05-13T19:06:53.782Z","repository":{"id":9858656,"uuid":"11855007","full_name":"chalk/supports-color","owner":"chalk","description":"Detect whether a terminal supports color","archived":false,"fork":false,"pushed_at":"2024-12-18T17:55:29.000Z","size":122,"stargazers_count":356,"open_issues_count":2,"forks_count":87,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-27T04:45:42.315Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"sabre1041/summit2016-ose-cicd","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chalk.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["sindresorhus","Qix-"]}},"created_at":"2013-08-03T00:01:50.000Z","updated_at":"2025-04-26T14:55:24.000Z","dependencies_parsed_at":"2025-02-13T16:00:30.813Z","dependency_job_id":"88d81e7b-6b9b-4062-9dad-aa9c39891693","html_url":"https://github.com/chalk/supports-color","commit_stats":{"total_commits":178,"total_committers":41,"mean_commits":4.341463414634147,"dds":0.3764044943820225,"last_synced_commit":"e06f284193939fbc1c75992871cda2b8192557ec"},"previous_names":["sindresorhus/has-color"],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chalk%2Fsupports-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chalk%2Fsupports-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chalk%2Fsupports-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chalk%2Fsupports-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chalk","download_url":"https://codeload.github.com/chalk/supports-color/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251089408,"owners_count":21534512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:18.846Z","updated_at":"2025-04-27T04:45:55.705Z","avatar_url":"https://github.com/chalk.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://github.com/sponsors/Qix-"],"categories":["JavaScript","others"],"sub_categories":[],"readme":"# supports-color\n\n\u003e Detect whether a terminal supports color\n\n## Install\n\n```sh\nnpm install supports-color\n```\n\n## Usage\n\n```js\nimport supportsColor from 'supports-color';\n\nif (supportsColor.stdout) {\n\tconsole.log('Terminal stdout supports color');\n}\n\nif (supportsColor.stdout.has256) {\n\tconsole.log('Terminal stdout supports 256 colors');\n}\n\nif (supportsColor.stderr.has16m) {\n\tconsole.log('Terminal stderr supports 16 million colors (truecolor)');\n}\n```\n\n## API\n\nReturns an `object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.\n\nThe `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:\n\n- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)\n- `.level = 2` and `.has256 = true`: 256 color support\n- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)\n\n### Custom instance\n\nThe package also exposes the named export `createSupportColor` function that takes an arbitrary write stream (for example, `process.stdout`) and an optional options object to (re-)evaluate color support for an arbitrary stream.\n\n```js\nimport {createSupportsColor} from 'supports-color';\n\nconst stdoutSupportsColor = createSupportsColor(process.stdout);\n\nif (stdoutSupportsColor) {\n\tconsole.log('Terminal stdout supports color');\n}\n\n// `stdoutSupportsColor` is the same as `supportsColor.stdout`\n```\n\nThe options object supports a single boolean property `sniffFlags`. By default it is `true`, which instructs the detection to sniff `process.argv` for the multitude of `--color` flags (see _Info_ below). If `false`, then `process.argv` is not considered when determining color support.\n\n## Info\n\nIt obeys the `--color` and `--no-color` CLI flags.\n\nFor situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.\n\nExplicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.\n\n## Related\n\n- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module\n- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right\n- [is-unicode-supported](https://github.com/sindresorhus/is-unicode-supported) - Detect whether the terminal supports Unicode\n- [is-interactive](https://github.com/sindresorhus/is-interactive) - Check if stdout or stderr is interactive\n\n## Maintainers\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [Josh Junon](https://github.com/qix-)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchalk%2Fsupports-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchalk%2Fsupports-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchalk%2Fsupports-color/lists"}