From 62adb912bdaf2a1e11679bb92d3a7c6ce3bcc6da Mon Sep 17 00:00:00 2001 From: Cecile Tonglet Date: Thu, 24 Sep 2020 09:53:08 +0200 Subject: [PATCH] Ensure icons are downloading properly before continuing build Fixes #12 --- build.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index e26f0ca..6024754 100644 --- a/build.rs +++ b/build.rs @@ -9,7 +9,7 @@ use std::process::Command; const ICON_URL: &str = "https://registry.npmjs.org/@blueprintjs/icons/-/icons-3.19.0.tgz"; const ICON_PATH: &str = "package/lib/esnext/generated/iconSvgPaths.js"; -fn main() -> Result<(), Box> { +fn main() { let icon_svg_paths = Command::new("sh") .arg("-c") .arg(format!( @@ -17,7 +17,8 @@ fn main() -> Result<(), Box> { ICON_URL, ICON_PATH )) .output() - .map(|x| String::from_utf8(x.stdout).expect("source file is not UTF-8"))?; + .map(|x| String::from_utf8(x.stdout).expect("source file is not UTF-8")) + .expect("could not download icons"); let out_dir = env::var_os("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("icon_svg_paths.rs"); @@ -42,6 +43,10 @@ fn main() -> Result<(), Box> { src.push_str(" }}\n\n"); } + if keys.is_empty() { + panic!("failed parse downloaded icons"); + } + let mut keys: Vec<_> = keys.iter().collect(); keys.sort(); src.push_str("#[derive(Debug, Copy, Clone, PartialEq)]\npub enum IconName {\n"); @@ -53,6 +58,4 @@ fn main() -> Result<(), Box> { fs::write(&dest_path, src).unwrap(); println!("cargo:rerun-if-changed=build.rs"); - - Ok(()) }