From 5772eba1cb228953ef1a78f860a02441bf5c05d0 Mon Sep 17 00:00:00 2001 From: Paul deGrandis Date: Mon, 22 Feb 2016 08:44:23 -0500 Subject: [PATCH] Disable color if the output stream is not a terminal; Fixes #4 --- mk.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mk.go b/mk.go index 95f7de8..df11f21 100644 --- a/mk.go +++ b/mk.go @@ -1,19 +1,21 @@ package main import ( - "bufio" + "bufio" "runtime" - "flag" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - "sync" + "flag" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" + "sync" + "github.com/mattn/go-isatty" ) // True if messages should be printed without fancy colors. -var nocolor bool = false +// - By default, if the output stream is not the terminal, colors are disabled +var nocolor bool = !isatty.IsTerminal(os.Stdout.Fd()) // True if we are ignoring timestamps and rebuilding everything. var rebuildall bool = false