-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbuild.rs
37 lines (32 loc) · 1002 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::{
fs,
path::Path,
process::{Command, ExitCode},
};
fn main() -> ExitCode {
println!("cargo::rerun-if-changed=src/themes.rs.tera");
// src/themes.rs.tera is excluded from the distributed crate so whiskers is
// not run if the crate is used as a dependency.
if !Path::new("src/themes.rs.tera").exists() {
return ExitCode::SUCCESS;
}
let outfile = fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open("src/themes.rs")
.unwrap();
let Ok(stat) = Command::new("whiskers")
.arg("src/themes.rs.tera")
.stdout(outfile)
.status()
else {
println!("cargo::warning=Failed to run whiskers (https://github.com/catppuccin/toolbox/tree/main/whiskers). Is it installed?");
return ExitCode::SUCCESS;
};
if !stat.success() {
println!("cargo::warning=whiskers exited nonzero");
return ExitCode::FAILURE;
}
ExitCode::SUCCESS
}