Skip to content

Commit 0e48387

Browse files
authored
fix: avoid blocking the installation script with an automatic update prompt (#246)
1 parent 4db880d commit 0e48387

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

internal/update/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (u *UpdateNotification) isCI() bool {
223223

224224
// isIgnoredCommand returns true when the process is in the list of commands.
225225
func (u *UpdateNotification) isIgnoredCommand() bool {
226-
ignoredCommands := []string{"version"}
226+
ignoredCommands := []string{"_fingerprint", "version"}
227227
osStr := os.Args[0:]
228228
if len(osStr) < 2 {
229229
return false

internal/update/update_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package update
1616

1717
import (
1818
"context"
19+
"os"
1920
"testing"
2021

2122
"github.com/slackapi/slack-cli/internal/config"
@@ -109,3 +110,39 @@ func Test_Update_HasUpdate(t *testing.T) {
109110
})
110111
}
111112
}
113+
114+
func Test_Update_isIgnoredCommand(t *testing.T) {
115+
for name, tt := range map[string]struct {
116+
command string
117+
expected bool
118+
}{
119+
"No command": {
120+
command: "",
121+
expected: false,
122+
},
123+
"fingerprint command": {
124+
command: "_fingerprint",
125+
expected: true,
126+
},
127+
"version command": {
128+
command: "version",
129+
expected: true,
130+
},
131+
"auth command": {
132+
command: "auth",
133+
expected: false,
134+
},
135+
} {
136+
t.Run(name, func(t *testing.T) {
137+
if tt.command != "" {
138+
os.Args = []string{"placeholder", tt.command}
139+
} else {
140+
os.Args = []string{"placeholder"}
141+
}
142+
// Test
143+
updateNotification := &UpdateNotification{}
144+
actual := updateNotification.isIgnoredCommand()
145+
require.Equal(t, tt.expected, actual)
146+
})
147+
}
148+
}

0 commit comments

Comments
 (0)