diff options
author | Vika <vika@fireburn.ru> | 2022-09-29 22:39:28 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2022-09-29 22:39:28 +0300 |
commit | b7d4e5c4686bc8aac41d832567190002542a1743 (patch) | |
tree | 6a42a990fbb06057a64de5f68175f94c3637c2c7 /kittybox-rs/build.rs | |
parent | b3508ccb146648950ed392b517d12354203c4347 (diff) | |
download | kittybox-b7d4e5c4686bc8aac41d832567190002542a1743.tar.zst |
companion-lite: port to TypeScript
Diffstat (limited to 'kittybox-rs/build.rs')
-rw-r--r-- | kittybox-rs/build.rs | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/kittybox-rs/build.rs b/kittybox-rs/build.rs index c9d6bfe..3d4c62b 100644 --- a/kittybox-rs/build.rs +++ b/kittybox-rs/build.rs @@ -2,18 +2,40 @@ fn main() { use std::env; let out_dir = env::var("OUT_DIR").unwrap(); println!("cargo:rerun-if-changed=javascript/"); - eprintln!("Out dir: {out_dir}"); - let mut child = std::process::Command::new("tsc") + if let Ok(exit) = std::process::Command::new("tsc") .arg("--outDir") - .arg(out_dir) + .arg(std::path::Path::new(&out_dir).join("kittybox_js")) .current_dir("javascript") .spawn() - .unwrap(); + .unwrap() + .wait() + { + if !exit.success() { + std::process::exit(exit.code().unwrap_or(1)) + } + } - if let Ok(exit) = child.wait() { + println!("cargo:rerun-if-changed=companion-lite/"); + let companion_out = std::path::Path::new(&out_dir).join("companion"); + + if let Ok(exit) = std::process::Command::new("tsc") + .arg("--outDir") + .arg(companion_out.as_os_str()) + .current_dir("companion-lite") + .spawn() + .unwrap() + .wait() + { if !exit.success() { std::process::exit(exit.code().unwrap_or(1)) } } + let companion_in = std::path::Path::new("companion-lite"); + for file in ["index.html", "style.css"] { + std::fs::copy( + companion_in.join(file), + &companion_out.join(file) + ).unwrap(); + } } |