Checking if the path already exists or not before creating the project

This commit is contained in:
Sridhar Ganesan 2018-07-23 15:40:15 +02:00
parent 6cc11d4b60
commit bfd928ca53
1 changed files with 8 additions and 4 deletions

View File

@ -146,8 +146,12 @@ benchmark:
func setupBasecoinWorkspace(projectName string, remoteProjectPath string) { func setupBasecoinWorkspace(projectName string, remoteProjectPath string) {
projectPath := resolveProjectPath(remoteProjectPath) projectPath := resolveProjectPath(remoteProjectPath)
fmt.Println("Configuring your project in " + projectPath) fmt.Println("Configuring your project in " + projectPath)
if _, err := os.Stat(projectPath); os.IsNotExist(err) {
copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) copyBasecoinTemplate(projectName, projectPath, remoteProjectPath)
createGopkg(projectPath) createGopkg(projectPath)
createMakefile(projectPath) createMakefile(projectPath)
fmt.Printf("\nInitialized a new project at %s.\nHappy hacking!\n", 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)
}
} }