Skip to content

Commit

Permalink
Fix “init” for an existing directory
Browse files Browse the repository at this point in the history
  • Loading branch information
rykov committed Jul 11, 2017
1 parent 959606a commit 8578dc0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ var newProjectCmd = &cobra.Command{
path, err := filepath.Abs(path)
if err != nil {
return err
} else if ok, _ := afero.Exists(mail.AppFs, path); ok {
return newUserError("%s already exists", path)
}

// Check for config to see if a project exists
configPath := filepath.Join(path, "config.toml")
if ok, _ := afero.Exists(mail.AppFs, configPath); ok {
return newUserError("%s already contains a project", path)
}

// Create project directories
Expand All @@ -130,7 +134,6 @@ var newProjectCmd = &cobra.Command{
}

// Write basic configuration
configPath := filepath.Join(path, "config.toml")
if err := writeTemplate(configPath, configTemplate, nil, true); err != nil {
return err
}
Expand Down

0 comments on commit 8578dc0

Please sign in to comment.