Skip to content

Commit 7c6cb97

Browse files
chikoskivados-cosmonic
authored andcommitted
Change to create the output directory if it does not exist (#118)
1 parent 9dc967c commit 7c6cb97

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

crates/wkg/src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{io::Seek, path::PathBuf};
1+
use std::{fs, io::Seek, path::PathBuf};
22

33
use anyhow::{ensure, Context};
44
use clap::{Args, Parser, Subcommand, ValueEnum};
@@ -359,7 +359,12 @@ impl GetArgs {
359359

360360
let output_trailing_slash = self.output.as_os_str().to_string_lossy().ends_with('/');
361361
let parent_dir = if output_trailing_slash {
362-
self.output.as_path()
362+
let parent_dir = self.output.as_path();
363+
if !fs::exists(parent_dir)? {
364+
fs::create_dir_all(parent_dir)
365+
.context("Failed to create output dir")?
366+
}
367+
parent_dir
363368
} else {
364369
self.output
365370
.parent()

0 commit comments

Comments
 (0)