Skip to content

Commit

Permalink
fix: create parent directories if they don't exist
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Brue <[email protected]>
  • Loading branch information
ryanabx committed Dec 19, 2024
1 parent e8d548e commit cc05fed
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,13 @@ fn generate_site_2(
if x_path.extension().is_some_and(|ext| ext == "md") {
let md = fs::read_to_string(x_path)?;
let html = markdown::md_to_html(&md, x_path.parent().unwrap(), web_prefix)?;
let _ = std::fs::create_dir_all(result_path.parent().unwrap());
if let Err(e) = std::fs::write(&result_path, html.as_bytes()) {
log::error!("Could not write file to path {:?}: {}", &result_path, e);
anyhow::bail!(e);
}
} else {
let _ = std::fs::create_dir_all(result_path.parent().unwrap());
if let Err(e) = std::fs::copy(x_path, &result_path) {
log::error!("Could not copy file from {:?} to {:?}: {}", x_path, &result_path, e);
anyhow::bail!(e);
Expand Down

0 comments on commit cc05fed

Please sign in to comment.