Skip to content

Commit 8578dc0

Browse files
committed
Fix “init” for an existing directory
1 parent 959606a commit 8578dc0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cmd/new.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@ var newProjectCmd = &cobra.Command{
118118
path, err := filepath.Abs(path)
119119
if err != nil {
120120
return err
121-
} else if ok, _ := afero.Exists(mail.AppFs, path); ok {
122-
return newUserError("%s already exists", path)
121+
}
122+
123+
// Check for config to see if a project exists
124+
configPath := filepath.Join(path, "config.toml")
125+
if ok, _ := afero.Exists(mail.AppFs, configPath); ok {
126+
return newUserError("%s already contains a project", path)
123127
}
124128

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

132136
// Write basic configuration
133-
configPath := filepath.Join(path, "config.toml")
134137
if err := writeTemplate(configPath, configTemplate, nil, true); err != nil {
135138
return err
136139
}

0 commit comments

Comments
 (0)