jotdown/examples/jotdown_wasm/build.rs
Noah Hellman 7a10767fed jotdown_wasm: display version
mostly useful for the hosted version
2023-04-05 21:17:33 +02:00

17 lines
525 B
Rust

fn get_version() -> String {
if let Ok(repo) = git2::Repository::discover(".") {
if let Ok(describe) = repo.describe(&git2::DescribeOptions::new()) {
if let Ok(format) = describe.format(None) {
return format;
}
}
}
std::env::var("CARGO_PKG_VERSION").unwrap()
}
fn main() {
let out_dir = std::env::var_os("OUT_DIR").unwrap();
let dest_path = std::path::Path::new(&out_dir).join("version");
std::fs::write(&dest_path, get_version()).unwrap();
}