Skip to content

Commit

Permalink
fix: check update panic
Browse files Browse the repository at this point in the history
  • Loading branch information
yuaanlin committed Apr 5, 2024
1 parent 3ea07b0 commit b37cd8b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions internal/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,22 @@ func NewCmdRoot(f *cmdutil.Factory, version, commit, date string) (*cobra.Comman

if f.AutoCheckUpdate && !f.Debug && version != "dev" {
currentVersion := TrimPrefixV(version)

upstreamVersionInfo, err := GetLatestRelease("zeabur/cli")
if err != nil {
return nil
}

upstreamVersion := TrimPrefixV(upstreamVersionInfo.TagName)

needUpdate, err := IsVersionNewerSemver(upstreamVersion, currentVersion)
if err != nil {
f.Log.Warn("Failed to get the latest version info from GitHub")
} else {
needUpdate, err := IsVersionNewerSemver(upstreamVersion, currentVersion)
if err != nil {
f.Log.Warnf("Failed to compare the current version with the latest version: %s", err.Error())
} else if needUpdate {
f.Log.Infof("A new version of Zeabur CLI is available: %s, you are using %s", upstreamVersion, currentVersion)
f.Log.Infof("Please visit %s to download the latest version", upstreamVersionInfo.URL)
}
return nil
}

if needUpdate {
f.Log.Infof("A new version of Zeabur CLI is available: %s, you are using %s", upstreamVersion, currentVersion)
f.Log.Infof("Please visit %s to download the latest version", upstreamVersionInfo.URL)
}
}

Expand Down

0 comments on commit b37cd8b

Please sign in to comment.