From 169660dbca36ee5db5090f2a9680ef3349a1184c Mon Sep 17 00:00:00 2001 From: Geoff Franks Date: Mon, 5 Feb 2018 21:07:25 -0500 Subject: [PATCH] Base diff colorization on stdout not stderr. Fixes #246 --- ci/release_notes.md | 8 ++++++++ cmd/spruce/main.go | 1 + 2 files changed, 9 insertions(+) create mode 100644 ci/release_notes.md diff --git a/ci/release_notes.md b/ci/release_notes.md new file mode 100644 index 00000000..0685f2b4 --- /dev/null +++ b/ci/release_notes.md @@ -0,0 +1,8 @@ +#Bug Fixes + +- `spruce diff` output used to be colorized based on whether or not STDERR was + sent to a terminal. This led to issues piping or redirecting the actual diff output, + so now the decision is based on what type of device STDOUT is. All other `spruce` + subcommands are unaffected, and continue to colorize based on STDERR's device type. + + Thanks @giner for pointing this out! diff --git a/cmd/spruce/main.go b/cmd/spruce/main.go index 1397506c..658f4d93 100644 --- a/cmd/spruce/main.go +++ b/cmd/spruce/main.go @@ -164,6 +164,7 @@ func main() { } case "diff": + ansi.Color(isatty.IsTerminal(os.Stdout.Fd())) if len(options.Diff.Files) != 2 { usage() return