File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 5
5
require (
6
6
github.com/fatih/color v1.7.0
7
7
github.com/mattn/go-colorable v0.1.2 // indirect
8
+ github.com/mattn/go-isatty v0.0.8
8
9
)
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import (
28
28
"unicode/utf8"
29
29
30
30
"github.com/fatih/color"
31
+ "github.com/mattn/go-isatty"
31
32
)
32
33
33
34
// errInvalidColor is returned when attempting to set an invalid color
@@ -271,7 +272,7 @@ func (s *Spinner) Active() bool {
271
272
// Start will start the indicator.
272
273
func (s * Spinner ) Start () {
273
274
s .mu .Lock ()
274
- if s .active {
275
+ if s .active || ! isRunningInTerminal () {
275
276
s .mu .Unlock ()
276
277
return
277
278
}
@@ -439,3 +440,8 @@ func GenerateNumberSequence(length int) []string {
439
440
}
440
441
return numSeq
441
442
}
443
+
444
+ // isRunningInTerminal check if stdout file descriptor is terminal
445
+ func isRunningInTerminal () bool {
446
+ return isatty .IsTerminal (os .Stdout .Fd ())
447
+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ github.com/fatih/color
5
5
## explicit
6
6
github.com/mattn/go-colorable
7
7
# github.com/mattn/go-isatty v0.0.8
8
+ ## explicit
8
9
github.com/mattn/go-isatty
9
10
# golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
10
11
golang.org/x/sys/unix
You can’t perform that action at this time.
0 commit comments