Skip to content

Commit 3dd4a54

Browse files
Merge pull request #2998 from augustoproiete-forks/opt-out-of-ansi-coloring-with-no_color-env-variable
GH-2975: Prevents the addition of ANSI color if NO_COLOR env. variable is present
2 parents 55c62c0 + e55cca4 commit 3dd4a54

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Cake.Core/Diagnostics/Console/AnsiDetector.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ static AnsiDetector()
4242

4343
public static bool SupportsAnsi(ICakeEnvironment environment)
4444
{
45+
// Prevents the addition of ANSI color if NO_COLOR env. variable is present
46+
// https://no-color.org
47+
if (!string.IsNullOrWhiteSpace(environment.GetEnvironmentVariable("NO_COLOR")))
48+
{
49+
return false;
50+
}
51+
4552
// Github action doesn't setup a correct PTY but supports ANSI.
4653
if (!string.IsNullOrWhiteSpace(environment.GetEnvironmentVariable("GITHUB_ACTION")))
4754
{

0 commit comments

Comments
 (0)