supports-color
Advanced tools
Comparing version 7.0.0 to 7.1.0
15
index.js
'use strict'; | ||
const os = require('os'); | ||
const tty = require('tty'); | ||
const hasFlag = require('has-flag'); | ||
@@ -43,3 +44,3 @@ | ||
function supportsColor(stream) { | ||
function supportsColor(haveStream, streamIsTTY) { | ||
if (forceColor === 0) { | ||
@@ -59,3 +60,3 @@ return 0; | ||
if (stream && !stream.isTTY && forceColor === undefined) { | ||
if (haveStream && !streamIsTTY && forceColor === undefined) { | ||
return 0; | ||
@@ -96,2 +97,6 @@ } | ||
if ('GITHUB_ACTIONS' in env) { | ||
return 1; | ||
} | ||
if (env.COLORTERM === 'truecolor') { | ||
@@ -129,3 +134,3 @@ return 3; | ||
function getSupportLevel(stream) { | ||
const level = supportsColor(stream); | ||
const level = supportsColor(stream, stream && stream.isTTY); | ||
return translateLevel(level); | ||
@@ -136,4 +141,4 @@ } | ||
supportsColor: getSupportLevel, | ||
stdout: getSupportLevel(process.stdout), | ||
stderr: getSupportLevel(process.stderr) | ||
stdout: translateLevel(supportsColor(true, tty.isatty(1))), | ||
stderr: translateLevel(supportsColor(true, tty.isatty(2))) | ||
}; |
{ | ||
"name": "supports-color", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"description": "Detect whether a terminal supports color", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
7052
118