Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Do not show colors in Windows CMD & Powershell" #140

Merged
merged 1 commit into from Apr 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions spinner.go
Expand Up @@ -100,8 +100,7 @@ var validColors = map[string]bool{
}

// returns true if the OS is windows and the WT_SESSION env variable is set.
var isWindows = runtime.OSOS == "windows"
var isWindowsTerminalOnWindows = len(os.Getenv("WT_SESSION")) > 0 && isWindows
var isWindowsTerminalOnWindows = len(os.Getenv("WT_SESSION")) > 0 && runtime.GOOS == "windows"

// returns a valid color's foreground text color attribute
var colorAttributeMap = map[string]color.Attribute{
Expand Down Expand Up @@ -282,12 +281,6 @@ func (s *Spinner) Start() {
// hides the cursor
fmt.Fprint(s.Writer, "\033[?25l")
}
// Disable colors for simple Windows CMD or Powershell
// as they can not recognize them
if isWindows && !isWindowsTerminalOnWindows {
color.NoColor = true
}

s.active = true
s.mu.Unlock()

Expand All @@ -312,7 +305,7 @@ func (s *Spinner) Start() {
}

var outColor string
if isWindows {
if runtime.GOOS == "windows" {
if s.Writer == os.Stderr {
outColor = fmt.Sprintf("\r%s%s%s", s.Prefix, s.chars[i], s.Suffix)
} else {
Expand Down