Create working directory if not exists

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

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)
}