Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Commit 19d0376

Browse files
committed
abort new workflow when dir exists
abort new workflow even when a directory with given name exists. currently we only abort if a file with the same name exists. reported via bug tool
1 parent 9a35e12 commit 19d0376

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

new.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,22 @@ so it does not conflict with any other Cloud Code in the current directory.
123123

124124
cloudCodeDirInfo, err := os.Stat(filepath.Join(e.Root, cloudCodeDir))
125125
if err == nil {
126-
if !cloudCodeDirInfo.IsDir() {
127-
return "", stackerr.Newf(`Sorry, we are unable to create Cloud Code at %s.
128-
In the current directory a file named: %s already exists.
126+
fileType := "file"
127+
if cloudCodeDirInfo.IsDir() {
128+
fileType = "directory"
129+
}
130+
return "", stackerr.Newf(`Sorry, we are unable to create Cloud Code at %s.
131+
In the current directory a %s named: %q already exists.
129132
Please run "parse new" again.
130133
%s
131134
Please choose a different name for your Cloud Code directory,
132135
so it does not conflict with any other Cloud Code in the current directory.
133136
`,
134-
cloudCodeDir,
135-
cloudCodeDir,
136-
helpMsg,
137-
)
138-
139-
}
140-
return "", nil
137+
cloudCodeDir,
138+
fileType,
139+
cloudCodeDir,
140+
helpMsg,
141+
)
141142
}
142143
if !os.IsNotExist(err) {
143144
return "", stackerr.Wrap(err)

0 commit comments

Comments
 (0)