Merge remote-tracking branch 'upstream/no-pack' into no-package

# Conflicts:
#	src/command/build.rs
master
Muhammad Hamza 2 years ago
commit 72f16aa2d4
No known key found for this signature in database
GPG Key ID: B7812BE5DBACA4E0
  1. 24
      src/command/build.rs
  2. 14
      tests/all/build.rs

@ -31,6 +31,7 @@ pub struct Build {
pub weak_refs: bool,
pub reference_types: bool,
pub target: Target,
pub no_pack: bool,
pub profile: BuildProfile,
pub mode: InstallMode,
pub out_dir: PathBuf,
@ -171,6 +172,10 @@ pub struct BuildOptions {
/// Sets the output file names. Defaults to package name.
pub out_name: Option<String>,
#[structopt(long = "no-pack")]
/// Option to not generate a package.json
pub no_pack: bool,
#[structopt(allow_hyphen_values = true)]
/// List of extra options to pass to `cargo build`
pub extra_options: Vec<String>,
@ -188,6 +193,7 @@ impl Default for BuildOptions {
target: Target::default(),
debug: false,
dev: false,
no_pack: false,
release: false,
profiling: false,
out_dir: String::new(),
@ -232,6 +238,7 @@ impl Build {
weak_refs: build_opts.weak_refs,
reference_types: build_opts.reference_types,
target: build_opts.target,
no_pack: build_opts.no_pack,
profile,
mode: build_opts.mode,
out_dir,
@ -249,7 +256,7 @@ impl Build {
/// Execute this `Build` command.
pub fn run(&mut self) -> Result<()> {
let process_steps = Build::get_process_steps(self.mode);
let process_steps = Build::get_process_steps(self.mode, self.no_pack);
let started = Instant::now();
@ -274,7 +281,7 @@ impl Build {
Ok(())
}
fn get_process_steps(mode: InstallMode) -> Vec<(&'static str, BuildStep)> {
fn get_process_steps(mode: InstallMode, no_pack: bool) -> Vec<(&'static str, BuildStep)> {
macro_rules! steps {
($($name:ident),+) => {
{
@ -296,16 +303,23 @@ impl Build {
]);
}
}
steps.extend(steps![
step_build_wasm,
step_create_dir,
step_copy_readme,
step_copy_license,
step_install_wasm_bindgen,
step_run_wasm_bindgen,
step_run_wasm_opt,
step_create_json,
]);
if !no_pack {
steps.extend(steps![
step_create_json,
step_copy_readme,
step_copy_license,
]);
}
steps
}

@ -21,6 +21,20 @@ fn it_should_build_js_hello_world_example() {
fixture.wasm_pack().arg("build").assert().success();
}
#[test]
fn it_should_not_make_a_pkg_json_if_passed_no_pack() {
let fixture = utils::fixture::js_hello_world();
fixture
.wasm_pack()
.arg("build")
.arg("--no-pack")
.assert()
.success();
let pkg_json_path = fixture.path.join("pkg").join("package.json");
assert_eq!(pkg_json_path.exists(), false);
}
#[test]
fn it_should_build_crates_in_a_workspace() {
let fixture = utils::fixture::Fixture::new();

Loading…
Cancel
Save