From 3899a4aba35852fe44e53d6b8d4429a2a36fd858 Mon Sep 17 00:00:00 2001 From: Jawad Tariq Date: Wed, 13 Mar 2024 18:00:49 -0400 Subject: [PATCH] feat: add build script for topos-sequencer-subnet-client Signed-off-by: Jawad Tariq --- crates/topos-sequencer-subnet-client/build.rs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 crates/topos-sequencer-subnet-client/build.rs diff --git a/crates/topos-sequencer-subnet-client/build.rs b/crates/topos-sequencer-subnet-client/build.rs new file mode 100644 index 000000000..85bb32441 --- /dev/null +++ b/crates/topos-sequencer-subnet-client/build.rs @@ -0,0 +1,36 @@ +use std::process::{exit, Command}; + +const CONTRACTS_PATH: &str = "../../contracts"; + +fn main() { + if !CONTRACTS_PATH.is_empty() { + std::env::set_current_dir(CONTRACTS_PATH).unwrap_or_else(|err| { + eprintln!("Error changing to subdirectory: {}", err); + exit(1); + }); + } + + Command::new("npm") + .arg("ci") + .status() + .unwrap_or_else(|err| { + eprintln!("Error executing npm ci: {}", err); + exit(1); + }); + + Command::new("npm") + .arg("run") + .arg("build") + .status() + .unwrap_or_else(|err| { + eprintln!("Error executing npm run build: {}", err); + exit(1); + }); + + std::env::set_current_dir("..").unwrap_or_else(|err| { + eprintln!("Error changing back to the original directory: {}", err); + exit(1); + }); + + println!("cargo:rerun-if-changed={}", CONTRACTS_PATH); +}