(out *os.File)
| 3 | import "os" |
| 4 | |
| 5 | func shouldUseColor(out *os.File) bool { |
| 6 | if os.Getenv("NO_COLOR") != "" { |
| 7 | return false |
| 8 | } |
| 9 | |
| 10 | if force := os.Getenv("FORCE_COLOR"); force != "" && force != "0" { |
| 11 | return true |
| 12 | } |
| 13 | |
| 14 | info, err := out.Stat() |
| 15 | if err != nil { |
| 16 | return false |
| 17 | } |
| 18 | |
| 19 | if info.Mode()&os.ModeCharDevice == 0 { |
| 20 | return false |
| 21 | } |
| 22 | |
| 23 | return platformColorSupported(out) |
| 24 | } |
no test coverage detected