From deff9e154bc0371af56741ddb22cb1f9e392838a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 24 Oct 2018 11:14:51 +0200 Subject: Add some color to the relevant filenames in terminal log Fixes #5344 --- common/herrors/error_locator.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'common/herrors') diff --git a/common/herrors/error_locator.go b/common/herrors/error_locator.go index 3f1aae689..cb59b65a3 100644 --- a/common/herrors/error_locator.go +++ b/common/herrors/error_locator.go @@ -18,8 +18,10 @@ import ( "fmt" "io" "io/ioutil" + "os" "strings" + "github.com/gohugoio/hugo/common/terminal" "github.com/gohugoio/hugo/helpers" "github.com/spf13/afero" @@ -27,6 +29,12 @@ import ( var fileErrorFormat = "\"%s:%d:%d\": %s" +func init() { + if terminal.IsTerminal(os.Stdout) { + fileErrorFormat = terminal.Notice("\"%s:%d:%d\"") + ": %s" + } +} + // LineMatcher contains the elements used to match an error to a line type LineMatcher struct { FileError FileError -- cgit v1.2.3