diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/character_sets.go golang-github-briandowns-spinner-1.18.1+ds1/character_sets.go --- golang-github-briandowns-spinner-1.18.0+ds1/character_sets.go 2021-12-19 05:04:36.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/character_sets.go 2022-02-07 17:03:21.000000000 +0000 @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Brian J. Downs +// Copyright (c) 2022 Brian J. Downs // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/debian/changelog golang-github-briandowns-spinner-1.18.1+ds1/debian/changelog --- golang-github-briandowns-spinner-1.18.0+ds1/debian/changelog 2021-12-31 09:14:33.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/debian/changelog 2022-03-03 17:13:44.000000000 +0000 @@ -1,3 +1,14 @@ +golang-github-briandowns-spinner (1.18.1+ds1-1) unstable; urgency=medium + + * Team upload. + * New upstream version 1.18.1+ds1 + * Add dependency on golang-github-mattn-go-isatty-dev as per go.mod + * Apply upstream patch to fix test error when not in terminal; + see debian/patches/0001-Skip-test-when-not-in-terminal.patch + * Update copyright years and add author's middle name initial + + -- Anthony Fok Thu, 03 Mar 2022 10:13:44 -0700 + golang-github-briandowns-spinner (1.18.0+ds1-1) unstable; urgency=medium * Team upload. diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/debian/control golang-github-briandowns-spinner-1.18.1+ds1/debian/control --- golang-github-briandowns-spinner-1.18.0+ds1/debian/control 2021-12-31 08:57:37.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/debian/control 2022-03-03 16:31:01.000000000 +0000 @@ -8,7 +8,8 @@ Build-Depends: debhelper-compat (= 13), dh-sequence-golang, golang-any, - golang-github-fatih-color-dev + golang-github-fatih-color-dev, + golang-github-mattn-go-isatty-dev Testsuite: autopkgtest-pkg-go Standards-Version: 4.6.0 Vcs-Browser: https://salsa.debian.org/go-team/packages/golang-github-briandowns-spinner @@ -20,7 +21,8 @@ Architecture: all Multi-Arch: foreign Depends: ${misc:Depends}, - golang-github-fatih-color-dev + golang-github-fatih-color-dev, + golang-github-mattn-go-isatty-dev Description: Go library for providing a terminal spinner/progress indicator with options golang-github-briandowns-spinner-dev is a simple library to add a spinner or progress indicator to any terminal application. diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/debian/copyright golang-github-briandowns-spinner-1.18.1+ds1/debian/copyright --- golang-github-briandowns-spinner-1.18.0+ds1/debian/copyright 2021-12-31 08:59:24.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/debian/copyright 2022-03-03 17:09:09.000000000 +0000 @@ -5,7 +5,7 @@ vendor Files: * -Copyright: 2014 Brian Downs +Copyright: 2014-2022 Brian J. Downs License: Apache-2.0 Files: debian/* diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/debian/patches/0001-Skip-test-when-not-in-terminal.patch golang-github-briandowns-spinner-1.18.1+ds1/debian/patches/0001-Skip-test-when-not-in-terminal.patch --- golang-github-briandowns-spinner-1.18.0+ds1/debian/patches/0001-Skip-test-when-not-in-terminal.patch 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/debian/patches/0001-Skip-test-when-not-in-terminal.patch 2022-03-03 16:37:14.000000000 +0000 @@ -0,0 +1,100 @@ +From 561dc95eeadf7fc57c2fe6ce2253f0f3361c0f75 Mon Sep 17 00:00:00 2001 +From: Brian Downs +Date: Sat, 12 Feb 2022 19:57:34 -0700 +Subject: [PATCH] Update ci (#132) + +--- + .circleci/config.yml | 27 +++++++++++++++++++++++++++ + README.md | 2 +- + spinner_test.go | 11 +++++++++++ + 3 files changed, 39 insertions(+), 1 deletion(-) + create mode 100644 .circleci/config.yml + +diff --git a/.circleci/config.yml b/.circleci/config.yml +new file mode 100644 +index 0000000..6dc18bc +--- /dev/null ++++ b/.circleci/config.yml +@@ -0,0 +1,27 @@ ++version: 2 ++jobs: ++ build: ++ docker: ++ - image: circleci/golang:1.17 ++ parallelism: 2 ++ steps: ++ - checkout ++ - restore_cache: ++ keys: ++ - go-mod-v4-{{ checksum "go.sum" }} ++ - run: make test ++ - save_cache: ++ key: go-mod-v4-{{ checksum "go.sum" }} ++ paths: ++ - "/go/pkg/mod" ++ - store_artifacts: ++ path: /tmp/test-results ++ destination: raw-test-output ++ ++ - store_test_results: ++ path: /tmp/test-results ++workflows: ++ version: 2 ++ build-workflow: ++ jobs: ++ - build +diff --git a/README.md b/README.md +index 20b315f..28b024d 100644 +--- a/README.md ++++ b/README.md +@@ -1,6 +1,6 @@ + # Spinner + +-[![GoDoc](https://godoc.org/github.com/briandowns/spinner?status.svg)](https://godoc.org/github.com/briandowns/spinner) [![Build Status](https://travis-ci.org/briandowns/spinner.svg?branch=master)](https://travis-ci.org/briandowns/spinner) ++[![GoDoc](https://godoc.org/github.com/briandowns/spinner?status.svg)](https://godoc.org/github.com/briandowns/spinner) [![CircleCI](https://circleci.com/gh/briandowns/spinner.svg?style=svg)](https://circleci.com/gh/briandowns/spinner) + + spinner is a simple package to add a spinner / progress indicator to any terminal application. Examples can be found below as well as full examples in the examples directory. + +diff --git a/spinner_test.go b/spinner_test.go +index cf3edfc..8ddf092 100644 +--- a/spinner_test.go ++++ b/spinner_test.go +@@ -18,10 +18,13 @@ import ( + "bytes" + "fmt" + "io/ioutil" ++ "os" + "reflect" + "sync" + "testing" + "time" ++ ++ "github.com/mattn/go-isatty" + ) + + const baseWait = 3 +@@ -69,6 +72,10 @@ func TestStart(t *testing.T) { + + // TestActive will verify we can tell when a spinner is running + func TestActive(t *testing.T) { ++ if !isatty.IsTerminal(os.Stdout.Fd()) { ++ t.Log("not running in a terminal") ++ return ++ } + s := New(CharSets[1], 100*time.Millisecond) + if s.Active() { + t.Error("expected a new spinner to not be active") +@@ -127,6 +134,10 @@ func TestRestart(t *testing.T) { + + // TestHookFunctions will verify that hook functions works as expected + func TestHookFunctions(t *testing.T) { ++ if !isatty.IsTerminal(os.Stdout.Fd()) { ++ t.Log("not running in a termian") ++ return ++ } + s := New(CharSets[4], 50*time.Millisecond) + var out syncBuffer + s.Writer = &out +-- +2.35.1 + diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/debian/patches/series golang-github-briandowns-spinner-1.18.1+ds1/debian/patches/series --- golang-github-briandowns-spinner-1.18.0+ds1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/debian/patches/series 2022-03-03 16:40:07.000000000 +0000 @@ -0,0 +1 @@ +0001-Skip-test-when-not-in-terminal.patch diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/_example/main.go golang-github-briandowns-spinner-1.18.1+ds1/_example/main.go --- golang-github-briandowns-spinner-1.18.0+ds1/_example/main.go 2021-12-19 05:04:36.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/_example/main.go 2022-02-07 17:03:21.000000000 +0000 @@ -16,11 +16,10 @@ s.UpdateCharSet(spinner.CharSets[9]) // Update spinner to use a different character set s.UpdateSpeed(100 * time.Millisecond) // Update the speed the spinner spins at - s.HideCursor = true - s.Prefix = "prefixed text: " // Prefix text before the spinner + s.Prefix = "prefixed text: " // Prefix text before the spinner time.Sleep(4 * time.Second) s.Prefix = "" - s.Suffix = " :appended text" // Append text after the spinner + s.Suffix = " :appended text" // Append text after the spinner time.Sleep(4 * time.Second) s.Prefix = "Colors: " @@ -48,7 +47,6 @@ } s.UpdateCharSet(spinner.CharSets[3]) - s.Restart() time.Sleep(4 * time.Second) // Run for some time to simulate work @@ -58,9 +56,7 @@ } s.UpdateCharSet(spinner.CharSets[28]) - s.Reverse() - s.Restart() time.Sleep(4 * time.Second) // Run for some time to simulate work @@ -70,7 +66,6 @@ } s.UpdateCharSet(spinner.CharSets[25]) - s.Restart() time.Sleep(4 * time.Second) // Run for some time to simulate work @@ -80,7 +75,6 @@ } s.UpdateCharSet(spinner.CharSets[32]) - s.Restart() time.Sleep(4 * time.Second) // Run for some time to simulate work @@ -92,7 +86,6 @@ s.FinalMSG = "Complete!\nNew line!\nAnother one!\n" s.UpdateCharSet(spinner.CharSets[31]) - s.Restart() time.Sleep(4 * time.Second) // Run for some time to simulate work @@ -101,7 +94,6 @@ s.Prefix = "Earth! " s.UpdateCharSet(spinner.CharSets[39]) - s.Restart() time.Sleep(4 * time.Second) // Run for some time to simulate work diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/go.mod golang-github-briandowns-spinner-1.18.1+ds1/go.mod --- golang-github-briandowns-spinner-1.18.0+ds1/go.mod 2021-12-19 05:04:36.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/go.mod 2022-02-07 17:03:21.000000000 +0000 @@ -5,4 +5,5 @@ require ( github.com/fatih/color v1.7.0 github.com/mattn/go-colorable v0.1.2 // indirect + github.com/mattn/go-isatty v0.0.8 ) diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/NOTICE.txt golang-github-briandowns-spinner-1.18.1+ds1/NOTICE.txt --- golang-github-briandowns-spinner-1.18.0+ds1/NOTICE.txt 2021-12-19 05:04:36.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/NOTICE.txt 2022-02-07 17:03:21.000000000 +0000 @@ -1,4 +1,4 @@ Spinner -Copyright (c) 2021 Brian J. Downs +Copyright (c) 2022 Brian J. Downs This product is licensed to you under the Apache 2.0 license (the "License"). You may not use this product except in compliance with the Apache 2.0 License. This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. diff -Nru golang-github-briandowns-spinner-1.18.0+ds1/spinner.go golang-github-briandowns-spinner-1.18.1+ds1/spinner.go --- golang-github-briandowns-spinner-1.18.0+ds1/spinner.go 2021-12-19 05:04:36.000000000 +0000 +++ golang-github-briandowns-spinner-1.18.1+ds1/spinner.go 2022-02-07 17:03:21.000000000 +0000 @@ -28,6 +28,7 @@ "unicode/utf8" "github.com/fatih/color" + "github.com/mattn/go-isatty" ) // errInvalidColor is returned when attempting to set an invalid color @@ -192,13 +193,14 @@ // New provides a pointer to an instance of Spinner with the supplied options. func New(cs []string, d time.Duration, options ...Option) *Spinner { s := &Spinner{ - Delay: d, - chars: cs, - color: color.New(color.FgWhite).SprintFunc(), - mu: &sync.RWMutex{}, - Writer: color.Output, - active: false, - stopChan: make(chan struct{}, 1), + Delay: d, + chars: cs, + color: color.New(color.FgWhite).SprintFunc(), + mu: &sync.RWMutex{}, + Writer: color.Output, + stopChan: make(chan struct{}, 1), + active: false, + HideCursor: true, } for _, option := range options { @@ -270,7 +272,7 @@ // Start will start the indicator. func (s *Spinner) Start() { s.mu.Lock() - if s.active { + if s.active || !isRunningInTerminal() { s.mu.Unlock() return } @@ -438,3 +440,8 @@ } return numSeq } + +// isRunningInTerminal check if stdout file descriptor is terminal +func isRunningInTerminal() bool { + return isatty.IsTerminal(os.Stdout.Fd()) +}