pub fn try_from_opts(mut build_opts: BuildOptions) -> Result<Self, Error> {
        if let Some(path) = &build_opts.path {
            if path.to_string_lossy().starts_with("--") {
                let path = build_opts.path.take().unwrap();
                build_opts
                    .extra_options
                    .insert(0, path.to_string_lossy().into_owned());
            }
        }
        let crate_path = get_crate_path(build_opts.path)?;
        let crate_data = manifest::CrateData::new(&crate_path, build_opts.out_name.clone())?;
        let out_dir = crate_path.join(PathBuf::from(build_opts.out_dir));

        let dev = build_opts.dev || build_opts.debug;
        let profile = match (dev, build_opts.release, build_opts.profiling) {
            (false, false, false) | (false, true, false) => BuildProfile::Release,
            (true, false, false) => BuildProfile::Dev,
            (false, false, true) => BuildProfile::Profiling,
            // Unfortunately, `structopt` doesn't expose clap's `conflicts_with`
            // functionality yet, so we have to implement it ourselves.
            _ => bail!("Can only supply one of the --dev, --release, or --profiling flags"),
        };

        Ok(Build {
            crate_path,
            crate_data,
            scope: build_opts.scope,
            disable_dts: build_opts.disable_dts,
            target: build_opts.target,
            profile,
            mode: build_opts.mode,
            out_dir,
            out_name: build_opts.out_name,
            bindgen: None,
            cache: cache::get_wasm_pack_cache()?,
            extra_options: build_opts.extra_options,
        })
    }
/// Construct a build command from the given options.
Construct a build command from the given options.
Construct a build command from the given options .
pub fn try_from_opts(mut build_opts: BuildOptions) -> Result<Self, Error> {
        if let Some(path) = &build_opts.path {
            if path.to_string_lossy().starts_with("--") {
                let path = build_opts.path.take().unwrap();
                build_opts
                    .extra_options
                    .insert(0, path.to_string_lossy().into_owned());
            }
        }
        let crate_path = get_crate_path(build_opts.path)?;
        let crate_data = manifest::CrateData::new(&crate_path, build_opts.out_name.clone())?;
        let out_dir = crate_path.join(PathBuf::from(build_opts.out_dir));
        let dev = build_opts.dev || build_opts.debug;
        let profile = match (dev, build_opts.release, build_opts.profiling) {
            (false, false, false) | (false, true, false) => BuildProfile::Release,
            (true, false, false) => BuildProfile::Dev,
            (false, false, true) => BuildProfile::Profiling,
            // Unfortunately, `structopt` doesn't expose clap's `conflicts_with`
            // functionality yet, so we have to implement it ourselves.
            _ => bail!("Can only supply one of the --dev, --release, or --profiling flags"),
        };
        Ok(Build {
            crate_path,
            crate_data,
            scope: build_opts.scope,
            disable_dts: build_opts.disable_dts,
            target: build_opts.target,
            profile,
            mode: build_opts.mode,
            out_dir,
            out_name: build_opts.out_name,
            bindgen: None,
            cache: cache::get_wasm_pack_cache()?,
            extra_options: build_opts.extra_options,
        })
    }
pub fn try_from_opts ( mut build_opts : BuildOptions ) -> Result < Self , Error > { if let Some ( path ) = & build_opts . path { if path . to_string_lossy ( ) . starts_with ( " " ) { let path = build_opts . path . take ( ) . unwrap ( ) ; build_opts . extra_options . insert ( 0 , path . to_string_lossy ( ) . into_owned ( ) ) ; } } let crate_path = get_crate_path ( build_opts . path ) ? ; let crate_data = manifest :: CrateData :: new ( & crate_path , build_opts . out_name . clone ( ) ) ? ; let out_dir = crate_path . join ( PathBuf :: from ( build_opts . out_dir ) ) ; let dev = build_opts . dev || build_opts . debug ; let profile = match ( dev , build_opts . release , build_opts . profiling ) { ( false , false , false ) | ( false , true , false ) => BuildProfile :: Release , ( true , false , false ) => BuildProfile :: Dev , ( false , false , true ) => BuildProfile :: Profiling , // Unfortunately, `structopt` doesn't expose clap's `conflicts_with` // functionality yet, so we have to implement it ourselves. _ => bail ! ( " " ) , } ; Ok ( Build { crate_path , crate_data , scope : build_opts . scope , disable_dts : build_opts . disable_dts , target : build_opts . target , profile , mode : build_opts . mode , out_dir , out_name : build_opts . out_name , bindgen : None , cache : cache :: get_wasm_pack_cache ( ) ? , extra_options : build_opts . extra_options , } ) }
Construct a build command from the given options.
Construct a build command from the given options .
build_opts
BuildOptions