Gathering detailed insights and metrics for support-color
Gathering detailed insights and metrics for support-color
Gathering detailed insights and metrics for support-color
Gathering detailed insights and metrics for support-color
npm install support-color
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
349 Stars
192 Commits
85 Forks
14 Watching
2 Branches
35 Contributors
Updated on 26 Nov 2024
JavaScript (97.08%)
TypeScript (2.92%)
Cumulative downloads
Total Downloads
Last day
33.3%
8
Compared to previous day
Last week
18.2%
26
Compared to previous week
Last month
-30.5%
89
Compared to previous month
Last year
-35.4%
2,164
Compared to previous year
1
3
Detect whether a terminal supports color
1npm install supports-color
1import supportsColor from 'supports-color'; 2 3if (supportsColor.stdout) { 4 console.log('Terminal stdout supports color'); 5} 6 7if (supportsColor.stdout.has256) { 8 console.log('Terminal stdout supports 256 colors'); 9} 10 11if (supportsColor.stderr.has16m) { 12 console.log('Terminal stderr supports 16 million colors (truecolor)'); 13}
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)The 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.
1import {createSupportsColor} from 'supports-color'; 2 3const stdoutSupportsColor = createSupportsColor(process.stdout); 4 5if (stdoutSupportsColor) { 6 console.log('Terminal stdout supports color'); 7} 8 9// `stdoutSupportsColor` is the same as `supportsColor.stdout`
The 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.
It obeys the --color
and --no-color
CLI flags.
For 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.
Explicit 256/Truecolor mode can be enabled using the --color=256
and --color=16m
flags, respectively.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 12/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More