supports-color 7.0.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +10 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  const os = require('os');
3
+ const tty = require('tty');
3
4
  const hasFlag = require('has-flag');
4
5
 
5
6
  const {env} = process;
@@ -40,7 +41,7 @@ function translateLevel(level) {
40
41
  };
41
42
  }
42
43
 
43
- function supportsColor(stream) {
44
+ function supportsColor(haveStream, streamIsTTY) {
44
45
  if (forceColor === 0) {
45
46
  return 0;
46
47
  }
@@ -55,7 +56,7 @@ function supportsColor(stream) {
55
56
  return 2;
56
57
  }
57
58
 
58
- if (stream && !stream.isTTY && forceColor === undefined) {
59
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
59
60
  return 0;
60
61
  }
61
62
 
@@ -91,6 +92,10 @@ function supportsColor(stream) {
91
92
  return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
92
93
  }
93
94
 
95
+ if ('GITHUB_ACTIONS' in env) {
96
+ return 1;
97
+ }
98
+
94
99
  if (env.COLORTERM === 'truecolor') {
95
100
  return 3;
96
101
  }
@@ -123,12 +128,12 @@ function supportsColor(stream) {
123
128
  }
124
129
 
125
130
  function getSupportLevel(stream) {
126
- const level = supportsColor(stream);
131
+ const level = supportsColor(stream, stream && stream.isTTY);
127
132
  return translateLevel(level);
128
133
  }
129
134
 
130
135
  module.exports = {
131
136
  supportsColor: getSupportLevel,
132
- stdout: getSupportLevel(process.stdout),
133
- stderr: getSupportLevel(process.stderr)
137
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
138
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
134
139
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supports-color",
3
- "version": "7.0.0",
3
+ "version": "7.1.0",
4
4
  "description": "Detect whether a terminal supports color",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/supports-color",