Skip to content

Commit

Permalink
Added logic to the bindgen::cargo_install_wasm_bindgen function to ch…
Browse files Browse the repository at this point in the history
…eck if 'wasm-bindgen' already exists in the path. This might need some revisions to be Windows compatible.
  • Loading branch information
data-pup committed Apr 6, 2018
1 parent ff3566e commit 7b45520
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use PBAR;
use console::style;
use emoji;
use std::process::Command;
use std::{env, fs, process::Command};

pub fn cargo_install_wasm_bindgen() {
if wasm_bindgen_installed() { return; }
let step = format!(
"{} {}Installing WASM-bindgen...",
style("[6/7]").bold().dim(),
Expand Down Expand Up @@ -36,3 +37,16 @@ pub fn wasm_bindgen_build(path: &str, name: &str) {
.unwrap_or_else(|e| panic!("{} failed to execute process: {}", emoji::ERROR, e));
pb.finish();
}

fn wasm_bindgen_installed() -> bool {
if let Ok(path) = env::var("PATH") {
return path.split(":")

This comment has been minimized.

Copy link
@data-pup

data-pup Apr 6, 2018

Author Owner

This line probably needs to be revised, so that a platform specific path separator is used to split the path string.

.map(|p: &str| -> bool {
let prog_str = format!("{}/{}", p, "wasm-bindgen");
fs::metadata(prog_str).is_ok()
})
.fold(false, |res, b| res || b);
} else {
return false;
}

This comment has been minimized.

Copy link
@data-pup

data-pup Apr 6, 2018

Author Owner

This section could be rewritten using a for loop, depending on style preferences.

}

0 comments on commit 7b45520

Please sign in to comment.