Skip to content

Commit

Permalink
Merge pull request #239 from lrbison/build
Browse files Browse the repository at this point in the history
Add error message to compile when Node is missing
  • Loading branch information
wash-amzn authored Dec 13, 2024
2 parents c88030f + c447eb1 commit 660c6f6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ fn main() -> Result<()> {

println!("cargo:rerun-if-changed=package.json");
println!("cargo:rerun-if-changed=package-lock.json");
let status = Command::new("npm").arg("install").spawn()?.wait()?;
if !status.success() {
std::process::exit(1);
match Command::new("npm").arg("install").spawn() {
Err(_proc) => {
println!("Build requires npm, but it was not found. Please install Node >= 16.16.0.");
std::process::exit(1);
}
Ok(mut child) => {
let status = child.wait()?;
if !status.success() {
println!("Command \"npm install\" failed.");
std::process::exit(1);
}
}
}

let jsdir = format!("{}/js", env::var("OUT_DIR").unwrap());
println!("cargo:rustc-env=JS_DIR={}", jsdir);
println!("cargo:rerun-if-changed=src/html_files/");
Expand All @@ -25,6 +35,7 @@ fn main() -> Result<()> {
.spawn()?
.wait()?;
if !status.success() {
println!("Failed to compile typescript.");
std::process::exit(1);
}
Ok(())
Expand Down

0 comments on commit 660c6f6

Please sign in to comment.