Skip to content

Commit

Permalink
Make sure update always fixes and updates the buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
Bios-Marcel committed Nov 22, 2024
1 parent cc87cfe commit 0a4a3af
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions cmd/spoon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,10 @@ func updateCmd() *cobra.Command {
Args: cobra.ArbitraryArgs,
ValidArgsFunction: autocompleteInstalled,
RunE: RunE(func(cmd *cobra.Command, args []string) error {
// If we have no args, it means update the buckets, instead of apps.
// We do this natively, as it's much faster and a rather easy task.
// However, we haven't implemented install yet, therefore we can't
// handle the actual updating of apps.
if len(args) > 0 || must(cmd.Flags().GetBool("all")) || !must(cmd.Flags().GetBool("experimental")) {
flags, err := getFlags(cmd, "force", "global", "indepdendent", "no-cache", "skip", "quiet", "all")
if err != nil {
return fmt.Errorf("error reading flags: %w", err)
}

os.Exit(execScoopCommand("update", append(flags, args...)...))
return nil
}
// Whenever we update, whether it is a certain app or the buckets,we
// always want to make sure everything is in good health and
// up-to-date. This is helpful, as scoop can break buckets
// when hitting ctrl-c during an update.

defaultScoop, err := scoop.NewScoop()
if err != nil {
Expand Down Expand Up @@ -92,6 +83,23 @@ func updateCmd() *cobra.Command {

waitgroup.Wait()

// We haven't implemented install yet, therefore we can't
// handle the actual updating of apps.
if len(args) > 0 || must(cmd.Flags().GetBool("all")) {
flags, err := getFlags(cmd, "force", "global", "indepdendent", "no-cache", "skip", "quiet", "all")
if err != nil {
return fmt.Errorf("error reading flags: %w", err)
}

if code := execScoopCommand("update", append(flags, args...)...); code != 0 {
os.Exit(code)
}

// No need to print status, as everything that can be
// updated, should be updated at this point in time
return nil
}

// Since you usually want to know whether anything has changed, we
// can just run this right away.
return status(defaultScoop)
Expand Down

0 comments on commit 0a4a3af

Please sign in to comment.