about summary refs log tree commit diff
path: root/kittybox-rs/templates/build.rs
blob: 1140060e262e2b1fcb463f35d06a2be8f18c3e11 (plain) (blame)
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
fn main() {
    use std::env;
    let out_dir = std::path::PathBuf::from(env::var("OUT_DIR").unwrap());
    println!("cargo:rerun-if-changed=assets/");
    let assets = std::fs::read_dir("assets").unwrap();
    for file in assets.map(|a| a.unwrap()) {
        std::fs::copy(
            file.path(),
            out_dir.join(file.file_name())
        )
            .unwrap();
    }
    println!("cargo::rerun-if-changed=javascript/");
    if let Ok(exit) = std::process::Command::new("tsc")
        .arg("--outDir")
        .arg(&out_dir)
        .current_dir("javascript")
        .spawn()
        .unwrap()
        .wait()
    {
        if !exit.success() {
            std::process::exit(exit.code().unwrap_or(1))
        }
    }
}