Skip to content

Commit

Permalink
Add --skip-build flag for init command
Browse files Browse the repository at this point in the history
this flag skip:
    adding target
    compiling to wasm
    installing wasm-bindgen
    running wasm-bindgen
  • Loading branch information
kohensu committed Jun 5, 2018
1 parent 1d946d6 commit 0960881
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 146 deletions.
25 changes: 9 additions & 16 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
use console::style;
use emoji;
use error::Error;
use progressbar::Step;
use std::process::Command;
use PBAR;

pub fn cargo_install_wasm_bindgen() -> Result<(), Error> {
let step = format!(
"{} {}Installing WASM-bindgen...",
style("[6/7]").bold().dim(),
emoji::DOWN_ARROW
);
let pb = PBAR.message(&step);
pub fn cargo_install_wasm_bindgen(step: &Step) -> Result<(), Error> {
let msg = format!("{}Installing WASM-bindgen...", emoji::DOWN_ARROW);
let pb = PBAR.step(step, &msg);
let output = Command::new("cargo")
.arg("install")
.arg("wasm-bindgen-cli")
Expand All @@ -33,14 +29,11 @@ pub fn wasm_bindgen_build(
path: &str,
name: &str,
disable_dts: bool,
target: String,
target: &str,
step: &Step,
) -> Result<(), Error> {
let step = format!(
"{} {}Running WASM-bindgen...",
style("[7/7]").bold().dim(),
emoji::RUNNER
);
let pb = PBAR.message(&step);
let msg = format!("{}Running WASM-bindgen...", emoji::RUNNER);
let pb = PBAR.step(step, &msg);
let binary_name = name.replace("-", "_");
let wasm_path = format!("target/wasm32-unknown-unknown/release/{}.wasm", binary_name);

Expand All @@ -50,7 +43,7 @@ pub fn wasm_bindgen_build(
"--no-typescript"
};

let target_arg = match target.as_str() {
let target_arg = match target {
"nodejs" => "--nodejs",
_ => "--browser",
};
Expand Down
22 changes: 7 additions & 15 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
use console::style;
use emoji;
use error::Error;
use progressbar::Step;
use std::process::Command;
use PBAR;

pub fn rustup_add_wasm_target() -> Result<(), Error> {
let step = format!(
"{} {}Adding WASM target...",
style("[1/7]").bold().dim(),
emoji::TARGET
);
let pb = PBAR.message(&step);
pub fn rustup_add_wasm_target(step: &Step) -> Result<(), Error> {
let msg = format!("{}Adding WASM target...", emoji::TARGET);
let pb = PBAR.step(step, &msg);
let output = Command::new("rustup")
.arg("target")
.arg("add")
Expand All @@ -25,13 +21,9 @@ pub fn rustup_add_wasm_target() -> Result<(), Error> {
}
}

pub fn cargo_build_wasm(path: &str) -> Result<(), Error> {
let step = format!(
"{} {}Compiling to WASM...",
style("[2/7]").bold().dim(),
emoji::CYCLONE
);
let pb = PBAR.message(&step);
pub fn cargo_build_wasm(path: &str, step: &Step) -> Result<(), Error> {
let msg = format!("{}Compiling to WASM...", emoji::CYCLONE);
let pb = PBAR.step(step, &msg);
let output = Command::new("cargo")
.current_dir(path)
.arg("build")
Expand Down
Loading

0 comments on commit 0960881

Please sign in to comment.