Skip to content

Commit

Permalink
Merge pull request #119 from kcmvp/upgrade-deps
Browse files Browse the repository at this point in the history
#117: print correct message when no need to update
  • Loading branch information
kcmvp authored Jun 16, 2024
2 parents 80e5376 + bf50fd4 commit 66281dd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cmd/gbc/command/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ func upgradeAll() error {
return !dependency.Indirect && dependency.Mod.Path == latest.A && dependency.Mod.Version != latest.B
})
})
args := lo.Union([]string{"get", "-u"}, lo.Map(candidates, func(latest lo.Tuple2[string, string], _ int) string {
return latest.A
}))
cmd := exec.Command("go", args...)
if err := artifact.PtyCmdOutput(cmd, "upgrading dependencies ......", false, nil); err != nil {
color.Red("failed to upgrade dependencies: %s", err.Error())
if len(candidates) > 0 {
args := lo.Union([]string{"get", "-u"}, lo.Map(candidates, func(latest lo.Tuple2[string, string], _ int) string {
return latest.A
}))
cmd := exec.Command("go", args...)
if err := artifact.PtyCmdOutput(cmd, "upgrading dependencies ......", false, nil); err != nil {
color.Red("failed to upgrade dependencies: %s", err.Error())
}
exec.Command("go", "mod", "tidy").CombinedOutput() //nolint
} else {
color.Green("all dependencies are latest")
}
exec.Command("go", "mod", "tidy").CombinedOutput() //nolint

return nil
}

Expand Down

0 comments on commit 66281dd

Please sign in to comment.