diff options
-rw-r--r-- | src/skaldpress/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/skaldpress/main.rs b/src/skaldpress/main.rs index 566fff3..5e44b8d 100644 --- a/src/skaldpress/main.rs +++ b/src/skaldpress/main.rs @@ -444,7 +444,6 @@ fn copy_files_in_directory(directory: &Path, opts: &Opts) -> Result<(), Skaldpre }; if metadata.is_file() { - println!("< Copying {:#?}", path.as_path()); let real_path = match path.strip_prefix(&opts.static_dir) { Ok(r) => r, Err(e) => { @@ -452,7 +451,20 @@ fn copy_files_in_directory(directory: &Path, opts: &Opts) -> Result<(), Skaldpre continue; } }; - let dest_file_path = Path::new(&opts.static_dir).join(real_path); + let dest_file_path = Path::new(&opts.build_dir).join(real_path); + println!( + "< Copying {:#?} -> {:#?}", + path.as_path(), + dest_file_path.as_path() + ); + let Some(dest_dir) = &dest_file_path.parent() else { + println!("\x1b[31mError creating dir {:#?}\x1b[0m", dest_file_path); + continue; + }; + if let Err(e) = std::fs::create_dir_all(&dest_dir) { + println!("\x1b[31mError creating dir {:#?}: {}\x1b[0m", dest_dir, e); + continue; + } if let Err(e) = std::fs::copy(&path, dest_file_path) { println!("\x1b[31mError copying {:#?}: {}\x1b[0m", path.as_path(), e); } |