Add support for NO_COLOR

This commit is contained in:
Martin Wickham
2021-06-21 13:47:38 -05:00
committed by Andrew Kelley
parent 7bdeda82ae
commit e2b954c273
7 changed files with 42 additions and 20 deletions

View File

@@ -90,11 +90,11 @@ pub fn getSelfDebugInfo() !*DebugInfo {
}
pub fn detectTTYConfig() TTY.Config {
var bytes: [128]u8 = undefined;
const allocator = &std.heap.FixedBufferAllocator.init(bytes[0..]).allocator;
if (process.getEnvVarOwned(allocator, "ZIG_DEBUG_COLOR")) |_| {
if (process.hasEnvVarConstant("ZIG_DEBUG_COLOR")) {
return .escape_codes;
} else |_| {
} else if (process.hasEnvVarConstant("NO_COLOR")) {
return .no_color;
} else {
const stderr_file = io.getStdErr();
if (stderr_file.supportsAnsiEscapeCodes()) {
return .escape_codes;