Skip to content

Commit 4fb97c3

Browse files
committed
Added error handling to wasm-bindgen install check.
1 parent f3f365e commit 4fb97c3

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/bindgen.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static PATH_SEP: &str = ";";
1111
static PATH_SEP: &str = ":";
1212

1313
pub fn cargo_install_wasm_bindgen() -> Result<(), Error> {
14-
if wasm_bindgen_installed() {
14+
if wasm_bindgen_installed()? {
1515
return Ok(());
1616
}
1717
let step = format!(
@@ -63,15 +63,13 @@ pub fn wasm_bindgen_build(path: &str, name: &str) -> Result<(), Error> {
6363
}
6464
}
6565

66-
fn wasm_bindgen_installed() -> bool {
67-
if let Ok(path) = env::var("PATH") {
68-
path.split(PATH_SEP)
69-
.map(|p: &str| -> bool {
70-
let prog_str = format!("{}/wasm-bindgen", p);
71-
fs::metadata(prog_str).is_ok()
72-
})
73-
.fold(false, |res, b| res || b)
74-
} else {
75-
false
76-
}
66+
fn wasm_bindgen_installed() -> Result<bool, Error> {
67+
let path = env::var("PATH")?;
68+
let is_installed = path.split(PATH_SEP)
69+
.map(|p: &str| -> bool {
70+
let prog_str = format!("{}/wasm-bindgen", p);
71+
fs::metadata(prog_str).is_ok()
72+
})
73+
.fold(false, |res, b| res || b);
74+
Ok(is_installed)
7775
}

0 commit comments

Comments
 (0)