This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jawad Tariq <[email protected]>
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use std::process::Command; | ||
|
||
const CONTRACTS_PATH: &str = "./contracts"; | ||
|
||
fn main() { | ||
compile_contracts(); | ||
} | ||
|
||
fn compile_contracts() { | ||
if !CONTRACTS_PATH.is_empty() { | ||
if let Err(err) = std::env::set_current_dir(CONTRACTS_PATH) { | ||
eprintln!("Error changing to subdirectory: {}", err); | ||
return; | ||
} | ||
} | ||
|
||
let install_result = Command::new("npm").arg("ci").status(); | ||
|
||
match install_result { | ||
Ok(status) => { | ||
if status.success() { | ||
println!( | ||
"npm dependencies installed successfully in {}!", | ||
CONTRACTS_PATH | ||
); | ||
} else { | ||
eprintln!( | ||
"Error installing npm dependencies in {}: {:?}", | ||
CONTRACTS_PATH, status | ||
); | ||
} | ||
} | ||
Err(err) => { | ||
eprintln!("Error executing npm ci: {}", err); | ||
} | ||
} | ||
|
||
let compile_result = Command::new("npm").arg("run").arg("build").status(); | ||
|
||
match compile_result { | ||
Ok(status) => { | ||
if status.success() { | ||
println!("Artifacts compiled successfully in {}!", CONTRACTS_PATH); | ||
} else { | ||
eprintln!( | ||
"Error compiling artifacts in {}: {:?}", | ||
CONTRACTS_PATH, status | ||
); | ||
} | ||
} | ||
Err(err) => { | ||
eprintln!("Error executing npm run build: {}", err); | ||
} | ||
} | ||
|
||
if let Err(err) = std::env::set_current_dir("..") { | ||
eprintln!("Error changing back to the original directory: {}", err); | ||
} | ||
|
||
// println!("cargo:rerun-if-changed={}", CONTRACTS_PATH); | ||
} |