Skip to content

Commit c3cc16b

Browse files
committed
Add --skip-build flag for init command
This flag skips: adding target compiling to wasm installing wasm-bindgen running wasm-bindgen
1 parent 06160a1 commit c3cc16b

File tree

8 files changed

+286
-159
lines changed

8 files changed

+286
-159
lines changed

src/bindgen.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
use console::style;
21
use emoji;
32
use error::Error;
3+
use progressbar::Step;
44
use std::process::Command;
55
use PBAR;
66

7-
pub fn cargo_install_wasm_bindgen() -> Result<(), Error> {
8-
let step = format!(
9-
"{} {}Installing WASM-bindgen...",
10-
style("[6/7]").bold().dim(),
11-
emoji::DOWN_ARROW
12-
);
13-
let pb = PBAR.message(&step);
7+
pub fn cargo_install_wasm_bindgen(step: &Step) -> Result<(), Error> {
8+
let msg = format!("{}Installing WASM-bindgen...", emoji::DOWN_ARROW);
9+
let pb = PBAR.step(step, &msg);
1410
let output = Command::new("cargo")
1511
.arg("install")
1612
.arg("wasm-bindgen-cli")
@@ -33,15 +29,12 @@ pub fn wasm_bindgen_build(
3329
path: &str,
3430
name: &str,
3531
disable_dts: bool,
36-
target: String,
32+
target: &str,
3733
debug: bool,
34+
step: &Step,
3835
) -> Result<(), Error> {
39-
let step = format!(
40-
"{} {}Running WASM-bindgen...",
41-
style("[7/7]").bold().dim(),
42-
emoji::RUNNER
43-
);
44-
let pb = PBAR.message(&step);
36+
let msg = format!("{}Running WASM-bindgen...", emoji::RUNNER);
37+
let pb = PBAR.step(step, &msg);
4538
let binary_name = name.replace("-", "_");
4639
let release_or_debug = if debug { "debug" } else { "release" };
4740
let wasm_path = format!(
@@ -54,7 +47,7 @@ pub fn wasm_bindgen_build(
5447
"--no-typescript"
5548
};
5649

57-
let target_arg = match target.as_str() {
50+
let target_arg = match target {
5851
"nodejs" => "--nodejs",
5952
_ => "--browser",
6053
};

src/build.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
use console::style;
21
use emoji;
32
use error::Error;
3+
use progressbar::Step;
44
use std::process::Command;
55
use PBAR;
66

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

28-
pub fn cargo_build_wasm(path: &str, debug: bool) -> Result<(), Error> {
29-
let step = format!(
30-
"{} {}Compiling to WASM...",
31-
style("[2/7]").bold().dim(),
32-
emoji::CYCLONE
33-
);
34-
let pb = PBAR.message(&step);
24+
pub fn cargo_build_wasm(path: &str, debug: bool, step: &Step) -> Result<(), Error> {
25+
let msg = format!("{}Compiling to WASM...", emoji::CYCLONE);
26+
let pb = PBAR.step(step, &msg);
3527
let output = {
3628
let mut cmd = Command::new("cargo");
3729
cmd.current_dir(path).arg("build");

0 commit comments

Comments
 (0)