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 skips:
    adding target
    compiling to wasm
    installing wasm-bindgen
    running wasm-bindgen
  • Loading branch information
kohensu committed Jun 13, 2018
1 parent 06160a1 commit c3cc16b
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 159 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,15 +29,12 @@ pub fn wasm_bindgen_build(
path: &str,
name: &str,
disable_dts: bool,
target: String,
target: &str,
debug: bool,
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 release_or_debug = if debug { "debug" } else { "release" };
let wasm_path = format!(
Expand All @@ -54,7 +47,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, debug: bool) -> 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, debug: bool, step: &Step) -> Result<(), Error> {
let msg = format!("{}Compiling to WASM...", emoji::CYCLONE);
let pb = PBAR.step(step, &msg);
let output = {
let mut cmd = Command::new("cargo");
cmd.current_dir(path).arg("build");
Expand Down
Loading

0 comments on commit c3cc16b

Please sign in to comment.