Skip to content

Commit

Permalink
synced with Node.js implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenZcience committed Aug 13, 2024
1 parent 0b358c3 commit 0d852aa
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions supports_color/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ def _supportsColor(haveStream, *, streamIsTTY, sniffFlags=True):

if has_flag('color=256'):
return 2

# // Check for Azure DevOps pipelines.
# // Has to be above the `!streamIsTTY` check.
# if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
# return 1;
# }
if 'TF_BUILD' in env and 'AGENT_NAME' in env:
return 1

#
# if (haveStream && !streamIsTTY && forceColor === undefined) {
# return 0;
Expand Down Expand Up @@ -119,15 +128,21 @@ def _supportsColor(haveStream, *, streamIsTTY, sniffFlags=True):
return 3 if int(osRelease[2]) >= 14931 else 2
return 1
# if ('CI' in env) {
# if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
# if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) {
# return 3;
# }
# if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
# return 1;
# }
#
# return min;
# }
if 'CI' in env:
if any([sign in env for sign in
['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE']]) or env.get(
if 'GITHUB_ACTIONS' in env or 'GITEA_ACTIONS' in env:
return 3

if any(sign in env for sign in
['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE']) or env.get(
'CI_NAME') == 'codeship':
return 1
#
Expand All @@ -143,6 +158,12 @@ def _supportsColor(haveStream, *, streamIsTTY, sniffFlags=True):
if env.get('COLORTERM') == 'truecolor':
return 3

# if (env.TERM === 'xterm-kitty') {
# return 3;
# }
if env.get('TERM') == 'xterm-kitty':
return 3

# Fix for iTerm2 via SSH
if env.get('LC_TERMINAL') == 'iTerm2':
return 3
Expand Down

0 comments on commit 0d852aa

Please sign in to comment.