From ac8168293592b4f9465b76181de6f1fb2524880a Mon Sep 17 00:00:00 2001 From: Zulkhair Abdullah Daim Date: Fri, 25 Oct 2024 14:24:18 +0700 Subject: [PATCH] check dir exist before create/clone --- common/teacmd/git.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/teacmd/git.go b/common/teacmd/git.go index 5a613be..e8501a3 100644 --- a/common/teacmd/git.go +++ b/common/teacmd/git.go @@ -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) + } + _, err := git("clone", url, targetDir) if err != nil { return err