Skip to content

Commit

Permalink
If STDOUT isn't a TTY, don't try to be interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
dshafik committed Nov 7, 2017
1 parent 66a2333 commit 90abfe7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 12 deletions.
5 changes: 5 additions & 0 deletions akamai.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (

"github.com/briandowns/spinner"
"github.com/fatih/color"
"github.com/mattn/go-isatty"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli"
"gopkg.in/src-d/go-git.v4"
Expand Down Expand Up @@ -690,6 +691,10 @@ func installPackage(dir string, forceBinary bool) bool {
status.Stop()
color.Cyan(err.Error())
if !forceBinary {
if !isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()) {
return false
}

fmt.Print("Binary command(s) found, would you like to try download and install it? (Y/n): ")
answer := ""
fmt.Scanln(&answer)
Expand Down
5 changes: 5 additions & 0 deletions firstrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ import (

"github.com/fatih/color"
"github.com/kardianos/osext"
"github.com/mattn/go-isatty"
)

func firstRun() error {
if !isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()) {
return nil
}

selfPath, err := osext.Executable()
if err != nil {
return err
Expand Down
28 changes: 16 additions & 12 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ import:
version: ^1.0.0
- package: github.com/src-d/go-git
version: ~4.0.0-rc13
- package: github.com/mattn/go-isatty
version: ^0.0.3
5 changes: 5 additions & 0 deletions upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ import (
"github.com/fatih/color"
"github.com/inconshreveable/go-update"
"github.com/kardianos/osext"
"github.com/mattn/go-isatty"
)

func checkForUpgrade(force bool) string {
if !isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()) {
return ""
}

cliPath, _ := getAkamaiCliPath()
upgradeFile := cliPath + string(os.PathSeparator) + ".upgrade-check"
data, err := ioutil.ReadFile(upgradeFile)
Expand Down

0 comments on commit 90abfe7

Please sign in to comment.