From bfd928ca53d677878ae4703f8aa8f78fef2c01f6 Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Mon, 23 Jul 2018 15:40:15 +0200 Subject: [PATCH] Checking if the path already exists or not before creating the project --- cmd/cosmos-sdk-cli/cmd/init.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index 555a035acf..5576ac2f31 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -146,8 +146,12 @@ benchmark: func setupBasecoinWorkspace(projectName string, remoteProjectPath string) { projectPath := resolveProjectPath(remoteProjectPath) fmt.Println("Configuring your project in " + projectPath) - copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) - createGopkg(projectPath) - createMakefile(projectPath) - fmt.Printf("\nInitialized a new project at %s.\nHappy hacking!\n", projectPath) + if _, err := os.Stat(projectPath); os.IsNotExist(err) { + copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) + createGopkg(projectPath) + createMakefile(projectPath) + fmt.Printf("\nInitialized a new project at %s.\nHappy hacking!\n", projectPath) + } else { + fmt.Printf("\n%s already exists, please choose a different project path\n", projectPath) + } }