initial commit
This commit is contained in:
commit
9f1e3bfcef
4 changed files with 680 additions and 0 deletions
65
src/main.rs
Normal file
65
src/main.rs
Normal file
|
@ -0,0 +1,65 @@
|
|||
use std::{
|
||||
ffi::OsString,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use walkdir::WalkDir;
|
||||
|
||||
fn main() {
|
||||
let src_dir = {
|
||||
let def = || OsString::from("./source/");
|
||||
let var = std::env::var_os("SOURCE_DIR").unwrap_or_else(def);
|
||||
PathBuf::from(var)
|
||||
};
|
||||
|
||||
let dst_dir = {
|
||||
let def = || OsString::from("./dist/");
|
||||
let var = std::env::var_os("DIST_DIR").unwrap_or_else(def);
|
||||
PathBuf::from(var)
|
||||
};
|
||||
|
||||
for ent in WalkDir::new(&src_dir) {
|
||||
let Ok(ent) = ent else { continue };
|
||||
|
||||
let src = ent.path();
|
||||
|
||||
if !src.is_file() && !src.is_symlink() {
|
||||
continue;
|
||||
}
|
||||
|
||||
match src.extension().map(|ext| ext.as_encoded_bytes()) {
|
||||
Some(b"md") => {
|
||||
let dst = get_dist_path(src, &src_dir, &dst_dir);
|
||||
if check_outdated(src, dst.with_extension("html"))
|
||||
|| check_outdated(src, dst.with_extension("gmi"))
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
Some(b"css") => {
|
||||
let dst = get_dist_path(src, &src_dir, &dst_dir);
|
||||
if check_outdated(src, dst) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get_dist_path(
|
||||
src: impl AsRef<Path>,
|
||||
src_dir: impl AsRef<Path>,
|
||||
dst_dir: impl AsRef<Path>,
|
||||
) -> PathBuf {
|
||||
dst_dir
|
||||
.as_ref()
|
||||
.join(src.as_ref().strip_prefix(&src_dir).unwrap())
|
||||
}
|
||||
|
||||
fn check_outdated(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> bool {
|
||||
true // TODO
|
||||
}
|
Loading…
Add table
Reference in a new issue