Create working directory if not exists

This commit is contained in:
世界 committed 2023-03-20 19:33:00 +08:00
1 parent fe4b429fc2
commit 84904c5206
5 files changed
+5 -5

No files matched your search

+4
View File
@@ -40,6 +40,10 @@ func preRun(cmd *cobra.Command, args []string) {
log.SetStdLogger(log.NewFactory(log.Formatter{BaseTime: time.Now(), DisableColors: true}, os.Stderr, nil).Logger())
}
if workingDir != "" {
_, err := os.Stat(workingDir)
if err != nil {
os.MkdirAll(workingDir, 0o777)
}
if err := os.Chdir(workingDir); err != nil {
log.Fatal(err)
}