[F] 💢💢💢💢💢
This commit is contained in:
parent
8c1713c37d
commit
b58425badd
6 changed files with 38 additions and 12 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
|
@ -220,6 +220,12 @@ version = "2.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||
|
||||
[[package]]
|
||||
name = "fs_extra"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.15"
|
||||
|
|
@ -245,7 +251,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|||
|
||||
[[package]]
|
||||
name = "hyfetch"
|
||||
version = "2.0.0-rc3"
|
||||
version = "2.0.0-rc4"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"ansi_colours",
|
||||
|
|
@ -258,6 +264,7 @@ dependencies = [
|
|||
"enable-ansi-support",
|
||||
"enterpolation",
|
||||
"fastrand",
|
||||
"fs_extra",
|
||||
"indexmap",
|
||||
"itertools",
|
||||
"normpath",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ resolver = "2"
|
|||
members = ["crates/*"]
|
||||
|
||||
[workspace.package]
|
||||
version = "2.0.0-rc3"
|
||||
version = "2.0.0-rc4"
|
||||
authors = ["Azalea Gui <azalea@hydev.org>"]
|
||||
edition = "2021"
|
||||
rust-version = "1.75.0"
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ which = { workspace = true, features = [] }
|
|||
indexmap = { workspace = true, features = ["std"] }
|
||||
regex = { workspace = true, features = ["perf", "std", "unicode"] }
|
||||
unicode-normalization = { workspace = true, features = ["std"] }
|
||||
fs_extra = "1.3.0"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
enable-ansi-support = { workspace = true, features = [] }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use std::env;
|
||||
use std::fmt::Write as _;
|
||||
use std::path::Path;
|
||||
use std::{env, fs};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use fs_extra::dir::{CopyOptions};
|
||||
use indexmap::IndexMap;
|
||||
use regex::Regex;
|
||||
use unicode_normalization::UnicodeNormalization as _;
|
||||
|
|
@ -23,15 +25,31 @@ impl AsciiDistro {
|
|||
}
|
||||
}
|
||||
|
||||
fn anything_that_exist(paths: &[&Path]) -> Option<PathBuf> {
|
||||
paths.iter().copied().find(|p| p.exists()).map(Path::to_path_buf)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let neofetch_path = Path::new(env!("CARGO_WORKSPACE_DIR")).join("neofetch");
|
||||
// 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 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 dst = o.join(file);
|
||||
println!("cargo:rerun-if-changed={}", src.display());
|
||||
|
||||
println!("cargo:rerun-if-changed={}", neofetch_path.display());
|
||||
// Copy either file or directory
|
||||
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");
|
||||
}
|
||||
else { fs::copy(&src, &dst).expect("Failed to copy file to OUT_DIR"); }
|
||||
}
|
||||
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
let out_path = Path::new(&out_dir);
|
||||
|
||||
export_distros(neofetch_path, out_path);
|
||||
export_distros(&o.join("neofetch"), &o);
|
||||
}
|
||||
|
||||
fn export_distros<P>(neofetch_path: P, out_path: &Path)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::collections::HashMap;
|
|||
use std::fs::{self, File};
|
||||
use std::io::{Read, Write};
|
||||
|
||||
const FONT_LOGOS: &str = include_str!(concat!(env!("CARGO_WORKSPACE_DIR"), "/hyfetch/data/font_logos.json"));
|
||||
const FONT_LOGOS: &str = include_str!(concat!(env!("OUT_DIR"), "/hyfetch/data/font_logos.json"));
|
||||
|
||||
pub fn get_font_logo(backend: Backend) -> Result<String> {
|
||||
// Check if the cache file exists and return its contents if it does
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ _/\_\_ _/_/\_
|
|||
pub const NEOFETCH_COLOR_PATTERNS: [&str; 6] =
|
||||
["${c1}", "${c2}", "${c3}", "${c4}", "${c5}", "${c6}"];
|
||||
pub static NEOFETCH_COLORS_AC: OnceLock<AhoCorasick> = OnceLock::new();
|
||||
pub const NEOFETCH_SCRIPT: &str = include_str!(concat!(env!("CARGO_WORKSPACE_DIR"), "/neofetch"));
|
||||
pub const NEOFETCH_SCRIPT: &str = include_str!(concat!(env!("OUT_DIR"), "/neofetch"));
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Debug, AsRefStr, Deserialize, Serialize)]
|
||||
#[serde(tag = "mode")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue