Skip to content

Commit 8a1b0f8

Browse files
authored
fix(CLI): Stuck waiting when using push -w -B (#1003)
1 parent e6db1fa commit 8a1b0f8

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

clients/cli/cmd/internal/print/print.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ func PhraseLogo() {
4646
// Prints the argument if the command is started in non-batch mode
4747
func NonBatchPrintf(msg string, args ...interface{}) {
4848
if !shared.BatchMode {
49-
fmt.Print(fmt.Sprintf(msg, args...))
49+
fmt.Printf(msg, args...)
50+
}
51+
}
52+
53+
func NonBatchPrint(msg string) {
54+
if !shared.BatchMode {
55+
fmt.Print(msg)
5056
}
5157
}
5258

clients/cli/cmd/internal/spinner/spinner.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package spinner
22

33
import (
4-
"fmt"
54
"time"
65

7-
"github.com/phrase/phrase-cli/cmd/internal/shared"
6+
"github.com/phrase/phrase-cli/cmd/internal/print"
87
)
98

109
// While executes f, displays an animated spinner while f runs, and stops when f returns.
@@ -33,18 +32,15 @@ func Until(c <-chan struct{}) {
3332

3433
// spin animates a spinner until it receives something on the stop channel. It then clears the spinning character and closes the stop channel, signaling that it's done.
3534
func spin(stop chan struct{}) {
36-
if shared.BatchMode {
37-
return
38-
}
3935
chars := []string{`-`, `\`, `|`, `/`}
40-
fmt.Print(" ")
36+
print.NonBatchPrint(" ")
4137
i := 0
4238
for {
43-
fmt.Print("\b")
44-
fmt.Print(chars[i])
39+
print.NonBatchPrint("\b")
40+
print.NonBatchPrint(chars[i])
4541
select {
4642
case <-stop:
47-
fmt.Print("\b ")
43+
print.NonBatchPrint("\b ")
4844
close(stop)
4945
return
5046
case <-time.After(100 * time.Millisecond):

clients/cli/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
215215
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
216216
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
217217
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
218-
github.com/phrase/phrase-go/v4 v4.9.0 h1:V+MWmNrxwrYNtmoY41dgrdWT902Er2hcohtQcpVvWmw=
219-
github.com/phrase/phrase-go/v4 v4.9.0/go.mod h1:4XplKvrbHS2LDaXfFp9xrVDtO5xk2WHFm0htutwwd8c=
218+
github.com/phrase/phrase-go/v4 v4.18.0 h1:LSD1izhuwF1TzxlLKdoItfyeSbCuiSs5RCmNiv8vmLg=
219+
github.com/phrase/phrase-go/v4 v4.18.0/go.mod h1:4XplKvrbHS2LDaXfFp9xrVDtO5xk2WHFm0htutwwd8c=
220220
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
221221
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
222222
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

0 commit comments

Comments
 (0)