Skip to content

Commit

Permalink
Check the COLORTERM variable for 16M color support (#75)
Browse files Browse the repository at this point in the history
According to https://gist.github.com/XVilka/8346728#detection and empirical tests on Konsole,
when `COLORTERM=truecolor`, 24-bit color support is guaranteed to work.
  • Loading branch information
jaens authored and sindresorhus committed Mar 2, 2018
1 parent b764af9 commit d6e08c8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ function supportsColor(stream) {
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
}

if (env.COLORTERM === 'truecolor') {
return 3;
}

if ('TERM_PROGRAM' in env) {
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);

Expand Down

0 comments on commit d6e08c8

Please sign in to comment.