|
|
|
@ -1,8 +1,9 @@ |
|
|
|
|
use PBAR; |
|
|
|
|
use console::style; |
|
|
|
|
use emoji; |
|
|
|
|
use failure::Error; |
|
|
|
|
use std::fs; |
|
|
|
|
use std::process::Command; |
|
|
|
|
use PBAR; |
|
|
|
|
|
|
|
|
|
pub fn cargo_install_wasm_bindgen() -> Result<(), Error> { |
|
|
|
|
let step = format!( |
|
|
|
@ -13,11 +14,15 @@ pub fn cargo_install_wasm_bindgen() -> Result<(), Error> { |
|
|
|
|
let pb = PBAR.message(&step); |
|
|
|
|
let output = Command::new("cargo") |
|
|
|
|
.arg("install") |
|
|
|
|
.arg("wasm-bindgen") |
|
|
|
|
.arg("wasm-bindgen-cli") |
|
|
|
|
.output()?; |
|
|
|
|
pb.finish(); |
|
|
|
|
if !output.status.success() { |
|
|
|
|
let s = String::from_utf8_lossy(&output.stderr); |
|
|
|
|
if s.contains("already exists") { |
|
|
|
|
PBAR.one_off_message("wasm-bindgen already installed"); |
|
|
|
|
return Ok(()); |
|
|
|
|
} |
|
|
|
|
PBAR.error("Installing wasm-bindgen failed"); |
|
|
|
|
bail!(format!("Details:\n{}", s)); |
|
|
|
|
} else { |
|
|
|
@ -46,6 +51,9 @@ pub fn wasm_bindgen_build(path: &str, name: &str) -> Result<(), Error> { |
|
|
|
|
PBAR.error("wasm-bindgen failed to execute properly"); |
|
|
|
|
bail!(format!("Details:\n{}", s)); |
|
|
|
|
} else { |
|
|
|
|
let js_file = format!("{}/pkg/{}.js", path, binary_name); |
|
|
|
|
let index_file = format!("{}/pkg/index.js", path); |
|
|
|
|
fs::rename(&js_file, &index_file)?; |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|