Skip to main content

zu_icon_util/
lib.rs

1// Copyright (c) 2024 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
2// Use of this source is governed by Lesser General Public License
3// that can be found in the LICENSE file.
4
5pub mod module;
6pub mod svg;
7
8use std::{fs, io};
9
10pub const UPDATE_KEY: &str = "UPDATE_ZU_ICONS";
11
12/// Check whether icon crate shall be refreshed.
13///
14/// Set `UPDATE_ZU_ICONS=1` environment to force update all icons.
15#[inline]
16#[must_use]
17pub fn need_update() -> bool {
18    std::env::var_os(UPDATE_KEY).is_some_and(|val| val != "0" && val != "false")
19}
20
21/// Remove all files in `src/` directory of crate
22pub fn reset_crate_source() -> Result<(), io::Error> {
23    fs::remove_dir_all("src")?;
24    fs::create_dir("src")?;
25    fs::write("src/lib.rs", "")
26}