File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ type IOStreams struct {
2020 Out io.Writer
2121 ErrOut io.Writer
2222
23+ // the original (non-colorable) output stream
24+ originalOut io.Writer
2325 colorEnabled bool
2426
2527 stdinTTYOverride bool
@@ -81,15 +83,16 @@ func (s *IOStreams) IsStderrTTY() bool {
8183
8284func (s * IOStreams ) TerminalWidth () int {
8385 defaultWidth := 80
84- if s .stdoutTTYOverride {
85- return defaultWidth
86+ out := s .Out
87+ if s .originalOut != nil {
88+ out = s .originalOut
8689 }
8790
88- if w , _ , err := terminalSize (s . Out ); err == nil {
91+ if w , _ , err := terminalSize (out ); err == nil {
8992 return w
9093 }
9194
92- if isCygwinTerminal (s . Out ) {
95+ if isCygwinTerminal (out ) {
9396 tputCmd := exec .Command ("tput" , "cols" )
9497 tputCmd .Stdin = os .Stdin
9598 if out , err := tputCmd .Output (); err == nil {
@@ -108,6 +111,7 @@ func System() *IOStreams {
108111
109112 io := & IOStreams {
110113 In : os .Stdin ,
114+ originalOut : os .Stdout ,
111115 Out : colorable .NewColorable (os .Stdout ),
112116 ErrOut : colorable .NewColorable (os .Stderr ),
113117 colorEnabled : os .Getenv ("NO_COLOR" ) == "" && stdoutIsTTY ,
You can’t perform that action at this time.
0 commit comments