Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --skip-build flag for init command #144 #151

Merged
merged 3 commits into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ The exact meaning of this flag may evolve as the platform matures.

[npm-scope-documentation]: https://docs.npmjs.com/misc/scope
[cargo-profile-sections-documentation]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections

## Skipping build

The init command accepts an optional `--skip-build` argument.

This will deactivate those steps:
- installing wasm target (via cargo)
- compiling the code to wasm
- installing wasm-bindgen (via rustup)
- running wasm-bindgen on the built wasm

Basically it will remains only the steps that update the metadata of `package.json`.
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