Skip to content
This repository was archived by the owner on Feb 16, 2025. It is now read-only.

Commit cc05fed

Browse files
committed
fix: create parent directories if they don't exist
Signed-off-by: Ryan Brue <[email protected]>
1 parent e8d548e commit cc05fed

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,13 @@ fn generate_site_2(
179179
if x_path.extension().is_some_and(|ext| ext == "md") {
180180
let md = fs::read_to_string(x_path)?;
181181
let html = markdown::md_to_html(&md, x_path.parent().unwrap(), web_prefix)?;
182+
let _ = std::fs::create_dir_all(result_path.parent().unwrap());
182183
if let Err(e) = std::fs::write(&result_path, html.as_bytes()) {
183184
log::error!("Could not write file to path {:?}: {}", &result_path, e);
184185
anyhow::bail!(e);
185186
}
186187
} else {
188+
let _ = std::fs::create_dir_all(result_path.parent().unwrap());
187189
if let Err(e) = std::fs::copy(x_path, &result_path) {
188190
log::error!("Could not copy file from {:?} to {:?}: {}", x_path, &result_path, e);
189191
anyhow::bail!(e);

0 commit comments

Comments
 (0)