Skip to content

Commit 0d75655

Browse files
committed
Mkdir for output dir if not exists
1 parent aa2c01b commit 0d75655

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

main.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ func main() {
192192
}
193193

194194
// Initialize output directory
195+
if _, err := os.Stat(flagOutputDir); os.IsNotExist(err) {
196+
if err := os.MkdirAll(flagOutputDir, 0750); err != nil {
197+
return fmt.Errorf("creating output directory %q: %v", flagOutputDir, err)
198+
}
199+
}
195200
empty, err := utils.DirIsEmpty(flagOutputDir)
196201
if err != nil {
197202
return fmt.Errorf("failed to check emptiness of output directory %q: %v", flagOutputDir, err)
@@ -266,7 +271,7 @@ The output directory is not empty. Please choose one of actions below:
266271
Name: "output-dir",
267272
EnvVars: []string{"AZTFY_OUTPUT_DIR"},
268273
Aliases: []string{"o"},
269-
Usage: "The output directory",
274+
Usage: "The output directory (will create if not exists)",
270275
Value: func() string {
271276
dir, _ := os.Getwd()
272277
return dir

0 commit comments

Comments
 (0)