diff --git a/cmd/timoni/artifact_pull.go b/cmd/timoni/artifact_pull.go index 2c36058d..3565cecd 100644 --- a/cmd/timoni/artifact_pull.go +++ b/cmd/timoni/artifact_pull.go @@ -107,8 +107,8 @@ func pullArtifactCmdRun(cmd *cobra.Command, args []string) error { log := LoggerFrom(cmd.Context()) - if fs, err := os.Stat(pullArtifactArgs.output); err != nil || !fs.IsDir() { - return fmt.Errorf("invalid output path %s", pullArtifactArgs.output) + if err := os.MkdirAll(pullArtifactArgs.output, os.ModePerm); err != nil { + return fmt.Errorf("invalid output path %s: %w", pullArtifactArgs.output, err) } if pullArtifactArgs.verify != "" { diff --git a/cmd/timoni/mod_pull.go b/cmd/timoni/mod_pull.go index f50c8a4f..775e489c 100644 --- a/cmd/timoni/mod_pull.go +++ b/cmd/timoni/mod_pull.go @@ -117,8 +117,8 @@ func pullCmdRun(cmd *cobra.Command, args []string) error { return fmt.Errorf("invalid output path %s", pullModArgs.output) } - if fs, err := os.Stat(pullModArgs.output); err != nil || !fs.IsDir() { - return fmt.Errorf("invalid output path %s", pullModArgs.output) + if err := os.MkdirAll(pullModArgs.output, os.ModePerm); err != nil { + return fmt.Errorf("invalid output path %s: %w", pullModArgs.output, err) } log := LoggerFrom(cmd.Context())