Skip to content

Commit

Permalink
feat: add -u, --update to update cached repo
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed May 10, 2020
1 parent ba48e88 commit 98ec292
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion spin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func main() {
repo := kingpin.Arg("repo", "Repository slug").Required().String()
target := kingpin.Arg("out-dir", "Output directory").Default(".").String()
clone := kingpin.Flag("clone", "Clone repository").Bool()
update := kingpin.Flag("update", "Update cached repository").Short('u').Bool()

kingpin.Parse()

Expand All @@ -27,7 +28,7 @@ func main() {
homedir, _ := os.UserHomeDir()
cacheDir := filepath.Join(homedir, fmt.Sprintf(".spin/templates/github/%s", *repo))

if !utils.PathExists(cacheDir) {
if !utils.PathExists(cacheDir) || *update {
if *clone == true {
if err := utils.GitClone(*repo, cacheDir); err != nil {
fmt.Println("error", err)
Expand All @@ -36,6 +37,7 @@ func main() {
} else {
url := fmt.Sprintf("https://github.com/%s/archive/master/archive.zip", *repo)

fmt.Println("Downloading..")
zipFile, err := utils.DownloadFile(url)

if err != nil {
Expand Down

0 comments on commit 98ec292

Please sign in to comment.