Skip to content

Commit

Permalink
chore: hide update banner when pinned
Browse files Browse the repository at this point in the history
  • Loading branch information
chase-crumbaugh committed Jan 22, 2025
1 parent f7d2170 commit d30accf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func setupRootCmd(version, artifactArch string) {
cmd.SetContext(ctx)

if !slices.Contains([]string{"update", "language-server"}, cmd.Name()) {
checkForUpdate(ctx, version, artifactArch)
checkForUpdate(ctx, version, artifactArch, cmd)
}

return setLogLevel(cmd)
Expand All @@ -143,7 +143,7 @@ func GetRootCommand() *cobra.Command {
return rootCmd
}

func checkForUpdate(ctx context.Context, currentVersion, artifactArch string) {
func checkForUpdate(ctx context.Context, currentVersion, artifactArch string, cmd *cobra.Command) {
// Don't display if piping to a file for example
if !utils.IsInteractive() {
return
Expand All @@ -153,6 +153,11 @@ func checkForUpdate(ctx context.Context, currentVersion, artifactArch string) {
return
}

// When using the --pinned flag, don't display update notifications
if flag := cmd.Flag("pinned"); flag != nil && flag.Value.String() == "true" {
return
}

newerVersion, err := updates.GetNewerVersion(ctx, artifactArch, currentVersion)
if err != nil {
return // Don't display error to user
Expand Down

0 comments on commit d30accf

Please sign in to comment.