diff --git a/Cargo.lock b/Cargo.lock index 61d48396..bf43e996 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -251,7 +251,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hyfetch" -version = "2.0.0-rc4" +version = "2.0.0-rc5" dependencies = [ "aho-corasick", "ansi_colours", diff --git a/Cargo.toml b/Cargo.toml index 55b54963..cf3db64d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["crates/*"] [workspace.package] -version = "2.0.0-rc4" +version = "2.0.0-rc5" authors = ["Azalea Gui "] edition = "2021" rust-version = "1.75.0" diff --git a/crates/hyfetch/build.rs b/crates/hyfetch/build.rs index e726bc4a..3af265fe 100644 --- a/crates/hyfetch/build.rs +++ b/crates/hyfetch/build.rs @@ -25,24 +25,18 @@ impl AsciiDistro { } } -fn anything_that_exist(paths: &[&Path]) -> Option { - 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"); }