From 2016b7a9285f4e8a830d9815780acfb239e647b1 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Sat, 6 Jul 2024 23:22:04 +0800 Subject: [PATCH] fix: skip version check if user is offline (#2498) --- cmd/root.go | 3 ++- internal/utils/release.go | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 94473f4a6..de3b9375d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -153,7 +153,8 @@ func Execute() { func checkUpgrade(ctx context.Context, fsys afero.Fs) (string, error) { if shouldFetchRelease(fsys) { version, err := utils.GetLatestRelease(ctx) - if exists, _ := afero.DirExists(fsys, utils.SupabaseDirPath); exists && len(version) > 0 { + if exists, _ := afero.DirExists(fsys, utils.SupabaseDirPath); exists { + // If user is offline, write an empty file to skip subsequent checks err = utils.WriteFile(utils.CliVersionPath, []byte(version), fsys) } return version, err diff --git a/internal/utils/release.go b/internal/utils/release.go index f855f51b6..e48df3b70 100644 --- a/internal/utils/release.go +++ b/internal/utils/release.go @@ -19,8 +19,7 @@ var ( func GetGtihubClient(ctx context.Context) *github.Client { githubOnce.Do(func() { var client *http.Client - token := os.Getenv("GITHUB_TOKEN") - if len(token) > 0 { + if token := os.Getenv("GITHUB_TOKEN"); len(token) > 0 { ts := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: token}, )