[F] 💢💢💢💢💢💢💢💢💢💢💢

This commit is contained in:
Azalea Gui 2025-08-21 09:52:03 -04:00
parent b58425badd
commit cf6b77a1b7
3 changed files with 5 additions and 11 deletions

2
Cargo.lock generated
View file

@ -251,7 +251,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hyfetch"
version = "2.0.0-rc4"
version = "2.0.0-rc5"
dependencies = [
"aho-corasick",
"ansi_colours",

View file

@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/*"]
[workspace.package]
version = "2.0.0-rc4"
version = "2.0.0-rc5"
authors = ["Azalea Gui <azalea@hydev.org>"]
edition = "2021"
rust-version = "1.75.0"

View file

@ -25,24 +25,18 @@ impl AsciiDistro {
}
}
fn anything_that_exist(paths: &[&Path]) -> Option<PathBuf> {
paths.iter().copied().find(|p| p.exists()).map(Path::to_path_buf)
}
fn main() {
// Path hack to make file paths work in both workspace and manifest directory
let p_ws = PathBuf::from(env::var_os("CARGO_WORKSPACE_DIR").unwrap());
let p_mn = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let dir = PathBuf::from(env::var_os("CARGO_WORKSPACE_DIR").unwrap_or_else(|| env::var_os("CARGO_MANIFEST_DIR").unwrap()));
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());
for file in &["neofetch", "hyfetch"] {
let src = anything_that_exist(&[&p_ws.join(file), &p_mn.join(file)])
.expect(&format!("{} not found in workspace or manifest directory", file));
let src = dir.join(file);
let dst = o.join(file);
println!("cargo:rerun-if-changed={}", src.display());
// Copy either file or directory
if src.is_dir() {
if src.is_dir() {
let opt = CopyOptions { overwrite: true, copy_inside: true, ..CopyOptions::default() };
fs_extra::dir::copy(&src, &dst, &opt).expect("Failed to copy directory to OUT_DIR");
}