fixed dir bug, reasonable defaults

This commit is contained in:
Logan 2024-09-07 15:18:30 -05:00
parent 8c8fbc91aa
commit f0f3a74dcb
2 changed files with 19 additions and 3 deletions

View file

@ -6,7 +6,7 @@ use std::{
};
fn main() {
let mut src_path = String::from("./");
let mut src_path = String::from("./src");
let mut dist_path = String::from("./dist");
for arg in std::env::args() {
if let Some(s) = arg.strip_prefix("--path=") {
@ -55,12 +55,29 @@ fn convert_all(src_path: &Path, dist_path: &Path) {
"css" => convert_css(file, src_path, dist_path),
"js" => convert_js(file, src_path, dist_path),
"json" => convert_json(file, src_path, dist_path),
_ => Ok(()),
_ => copy(file, src_path, dist_path),
}
.unwrap();
}
}
fn copy(
file: &Path,
src_path: &Path,
dist_path: &Path,
) -> Result<(), std::io::Error> {
if file.is_dir() {
return Ok(());
}
let file_contents = std::fs::read(file)?;
let dist_path = dist_path.join(file.strip_prefix(src_path).unwrap_or(file));
if let Some(path) = dist_path.parent() {
let _ = std::fs::create_dir_all(path);
}
std::fs::File::create(dist_path)?.write(&file_contents)?;
Ok(())
}
fn convert_md(
file: &Path,
src_path: &Path,

View file

@ -1 +0,0 @@
# hello world