Skip to content

Commit

Permalink
move exists() to main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
intrand committed Sep 10, 2022
1 parent 85674c8 commit c5958c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 0 additions & 12 deletions asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ import (
"github.com/google/go-github/v47/github"
)

// exists returns whether the given file or directory exists
func exists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}

func downloadAsset(ctx context.Context, asset *github.ReleaseAsset, path string) (err error) {
client, org, repo, err := getGithubClient()
if err != nil {
Expand Down
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ type Version struct {
BuiltBy string `json:"builtBy"`
}

// exists returns whether the given file or directory exists
func exists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}

func mkTempDir(tagName string) (dir string, err error) {
dir = os.TempDir() // get tmp dir (usually /tmp)
if err != nil {
Expand Down Expand Up @@ -127,7 +139,7 @@ func main() {
}

if exist {
log.Println("Already exists. Nothing to do. Exiting.")
log.Println("Release " + *latestRelease.TagName + " already exists on this console. Nothing to do. Exiting.")
os.Exit(0)
} // end exists

Expand Down

0 comments on commit c5958c9

Please sign in to comment.