diff --git a/src/command/build.rs b/src/command/build.rs index 8832cef..689dab4 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -1,8 +1,6 @@ -//! Initializing a crate for packing `.wasm`s. - use bindgen; use build; -use command::utils::{set_crate_path, create_pkg_dir}; +use command::utils::{create_pkg_dir, set_crate_path}; use emoji; use error::Error; use indicatif::HumanDuration; @@ -35,7 +33,7 @@ pub enum BuildMode { } /// Everything required to configure and run the `wasm-pack build` command. -#[derive(Debug,StructOpt)] +#[derive(Debug, StructOpt)] pub struct BuildOptions { /// The path to the Rust crate. pub path: Option<String>, @@ -60,7 +58,6 @@ pub struct BuildOptions { #[structopt(long = "debug")] /// Build without --release. debug: bool, - // build config from manifest // build_config: Option<BuildConfig>, } @@ -72,10 +69,10 @@ impl From<BuildOptions> for Build { // let build_config = manifest::xxx(&crate_path).xxx(); Build { crate_path, - scope:build_opts.scope, - disable_dts:build_opts.disable_dts, - target:build_opts.target, - debug:build_opts.debug, + scope: build_opts.scope, + disable_dts: build_opts.disable_dts, + target: build_opts.target, + debug: build_opts.debug, // build_config, crate_name, } @@ -85,7 +82,7 @@ impl From<BuildOptions> for Build { type BuildStep = fn(&mut Build, &Step, &Logger) -> Result<(), Error>; impl Build { - /// Execute this `Init` command. + /// Execute this `Build` command. pub fn run(&mut self, log: &Logger, mode: BuildMode) -> Result<(), Error> { let process_steps = Build::get_process_steps(mode); @@ -148,7 +145,6 @@ impl Build { } } - fn step_check_crate_config(&mut self, step: &Step, log: &Logger) -> Result<(), Error> { info!(&log, "Checking crate configuration..."); manifest::check_crate_config(&self.crate_path, step)?; diff --git a/src/command/init.rs b/src/command/init.rs index 09e7ff5..7f6213b 100644 --- a/src/command/init.rs +++ b/src/command/init.rs @@ -1,6 +1,6 @@ //! Initializing a crate for packing `.wasm`s. -use command::utils::{set_crate_path,create_pkg_dir}; +use command::utils::{create_pkg_dir, set_crate_path}; use emoji; use error::Error; use indicatif::HumanDuration; @@ -41,8 +41,6 @@ pub struct Init { scope: Option<String>, disable_dts: bool, target: String, - // build without --release. - debug: bool, } /// `Init` options @@ -63,22 +61,16 @@ pub struct InitOptions { #[structopt(long = "target", short = "t", default_value = "browser")] /// Sets the target environment. [possible values: browser, nodejs] pub target: String, - - #[structopt(long = "debug")] - /// Build without --release. - pub debug: bool, } impl From<InitOptions> for Init { fn from(init_opts: InitOptions) -> Self { let crate_path = set_crate_path(init_opts.path); - let crate_name = manifest::get_crate_name(&crate_path).unwrap(); - Init { + Init { crate_path, scope: init_opts.scope, - disable_dts:init_opts.disable_dts, - target:init_opts.target, - debug:init_opts.debug, + disable_dts: init_opts.disable_dts, + target: init_opts.target, } } } diff --git a/src/command/mod.rs b/src/command/mod.rs index 0e9a4e4..a9e555f 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -7,11 +7,11 @@ mod pack; mod publish; pub mod utils; +use self::build::{Build, BuildMode}; +use self::init::Init; use self::login::login; use self::pack::pack; use self::publish::publish; -use self::build::{Build,BuildMode}; -use self::init::Init; use error::Error; use slog::Logger; use std::path::PathBuf; diff --git a/src/command/utils.rs b/src/command/utils.rs index 3e0fb70..220f60c 100644 --- a/src/command/utils.rs +++ b/src/command/utils.rs @@ -1,6 +1,11 @@ //! Utility functions for commands. use std::path::{Path, PathBuf}; +use emoji; +use error::Error; +use progressbar::Step; +use std::fs; +use PBAR; /// If an explicit path is given, then use it, otherwise assume the current /// directory is the crate path.