forked from rustwasm/wasm-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logic to the bindgen::cargo_install_wasm_bindgen function to ch…
…eck if 'wasm-bindgen' already exists in the path. This might need some revisions to be Windows compatible.
- Loading branch information
Showing
1 changed file
with
15 additions
and
1 deletion.
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 |
---|---|---|
@@ -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(), | ||
|
@@ -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.
Sorry, something went wrong. |
||
.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.
Sorry, something went wrong.
data-pup
Author
Owner
|
||
} |
This line probably needs to be revised, so that a platform specific path separator is used to split the path string.