Skip to content

Commit 1dc8360

Browse files
committed
Disable diagnostics ANSI color for non-terminal
If stdout is not a terminal device, don't color the output. Alternative considered: * Use [IsTTY](https://github.com/dduan/istty). * Add a auto color option
1 parent 00945ab commit 1dc8360

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/FileCheck/Diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22

33
func diagnose(_ kind : DiagnosticKind, at loc : CheckLocation, with message : String, options: FileCheckOptions) {
4-
let disableColors = options.contains(.disableColors)
4+
let disableColors = options.contains(.disableColors) || isatty(fileno(stdout)) == 1
55
if disableColors {
66
print("\(kind): \(message)")
77
} else {

0 commit comments

Comments
 (0)