Skip to content

Commit

Permalink
Fix test for Azure DevOps environment (#128)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
josundt and sindresorhus authored Dec 7, 2022
1 parent 994b873 commit 848b80e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
}
}

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

if (haveStream && !streamIsTTY && forceColor === undefined) {
return 0;
}
Expand Down Expand Up @@ -120,11 +126,6 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
}

// Check for Azure DevOps pipelines
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
return 1;
}

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

0 comments on commit 848b80e

Please sign in to comment.