Merge pull request #12066 from andriyDev/fix-download-pb-not-tty

Make download.download not use progress bar if not in tty.
pull/12069/head
Medya Ghazizadeh 2021-07-28 12:08:41 -07:00 committed by GitHub
commit 44feb06fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -51,9 +51,15 @@ func CreateDstDownloadMock(src, dst string) error {
// download is a well-configured atomic download function
func download(src string, dst string) error {
progress := getter.WithProgress(DefaultProgressBar)
if out.JSON {
progress = getter.WithProgress(DefaultJSONOutput)
var clientOptions []getter.ClientOption
if out.IsTerminal(os.Stdout) {
progress := getter.WithProgress(DefaultProgressBar)
if out.JSON {
progress = getter.WithProgress(DefaultJSONOutput)
}
clientOptions = []getter.ClientOption{progress}
} else {
clientOptions = []getter.ClientOption{}
}
tmpDst := dst + ".download"
client := &getter.Client{
@ -61,7 +67,7 @@ func download(src string, dst string) error {
Dst: tmpDst,
Dir: false,
Mode: getter.ClientModeFile,
Options: []getter.ClientOption{progress},
Options: clientOptions,
Getters: map[string]getter.Getter{
"file": &getter.FileGetter{Copy: false},
"http": &getter.HttpGetter{Netrc: false},