Skip to content

Commit

Permalink
check dir exist before create/clone
Browse files Browse the repository at this point in the history
  • Loading branch information
zulkhair committed Oct 25, 2024
1 parent 84f5fb5 commit ac81682
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/teacmd/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func git(args ...string) (string, error) {
}

func GitCloneCmd(url string, targetDir string, initMsg string) error {
// check targetDir exists
if _, err := os.Stat(targetDir); err == nil {
return eris.Errorf("Game shard named '%s' already exists in this directory, please change the directory or use another name", targetDir)

Check failure on line 52 in common/teacmd/git.go

View workflow job for this annotation

GitHub Actions / Go

line is 138 characters (lll)

Check failure on line 52 in common/teacmd/git.go

View workflow job for this annotation

GitHub Actions / Go

line is 138 characters (lll)
}

_, err := git("clone", url, targetDir)
if err != nil {
return err
Expand Down

0 comments on commit ac81682

Please sign in to comment.