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

fix,feat: assume tty using environment variables #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion termenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import (
"errors"
"strconv"

"github.com/mattn/go-isatty"
)
Expand All @@ -12,13 +13,13 @@
)

const (
// Escape character

Check failure on line 16 in termenv.go

View workflow job for this annotation

GitHub Actions / lint-soft

Comment should end in a period (godot)
ESC = '\x1b'
// Bell

Check failure on line 18 in termenv.go

View workflow job for this annotation

GitHub Actions / lint-soft

Comment should end in a period (godot)
BEL = '\a'
// Control Sequence Introducer

Check failure on line 20 in termenv.go

View workflow job for this annotation

GitHub Actions / lint-soft

Comment should end in a period (godot)
CSI = string(ESC) + "["
// Operating System Command

Check failure on line 22 in termenv.go

View workflow job for this annotation

GitHub Actions / lint-soft

Comment should end in a period (godot)
OSC = string(ESC) + "]"
// String Terminator
ST = string(ESC) + `\`
Expand All @@ -28,9 +29,15 @@
if o.assumeTTY || o.unsafe {
return true
}
if len(o.environ.Getenv("CI")) > 0 {

if isCI, err := strconv.ParseBool(o.environ.Getenv("CI")); err == nil && isCI {
return false
}

if isTty, err := strconv.ParseBool(o.environ.Getenv("TERMENV_TTY")); err == nil {
return isTty
}

if o.TTY() == nil {
return false
}
Expand Down