Skip to content

Commit

Permalink
Use golang.org/x/crypto/ssh/terminal instead of github.com/mattn/go-i…
Browse files Browse the repository at this point in the history
…satty
  • Loading branch information
twpayne committed Jan 10, 2020
1 parent acf3478 commit 0b3aa77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"

"github.com/charmbracelet/glamour"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
)
Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *Config) runDocsCmd(cmd *cobra.Command, args []string) error {
}

width := 80
if stdout, ok := c.Stdout().(*os.File); ok && isatty.IsTerminal(stdout.Fd()) {
if stdout, ok := c.Stdout().(*os.File); ok && terminal.IsTerminal(int(stdout.Fd())) {
width, _, err = terminal.GetSize(int(stdout.Fd()))
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

"github.com/Masterminds/sprig"
"github.com/coreos/go-semver/semver"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/twpayne/chezmoi/internal/chezmoi"
vfs "github.com/twpayne/go-vfs"
xdg "github.com/twpayne/go-xdg/v3"
"golang.org/x/crypto/ssh/terminal"
)

var config = Config{
Expand Down Expand Up @@ -140,7 +140,7 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
c.colored = false
case "auto":
if stdout, ok := c.Stdout().(*os.File); ok {
c.colored = isatty.IsTerminal(stdout.Fd())
c.colored = terminal.IsTerminal(int(stdout.Fd()))
} else {
c.colored = false
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/huandu/xstrings v1.2.1 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 // indirect
github.com/mattn/go-isatty v0.0.11
github.com/mattn/go-isatty v0.0.11 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/pelletier/go-toml v1.6.0 // indirect
Expand Down

0 comments on commit 0b3aa77

Please sign in to comment.