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

Conversation

kohensu
Copy link
Contributor

@kohensu kohensu commented Jun 5, 2018

pull request for #144

@kohensu kohensu force-pushed the add_--skip-build_flag_#144 branch from 5e7f4eb to 0960881 Compare June 5, 2018 21:46
@ashleygwilliams ashleygwilliams added this to the 0.4.0 milestone Jun 5, 2018
Copy link
Member

@ashleygwilliams ashleygwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey! i've given this a first pass and tbh i think it's really fantastic- awesome job! i have a few comments, but one is a style nit and the other is potentially something to implement at a later date. i want to pull this down and run it (not cuz i don't trust you, but because i don't trust our tests)... but in general i think this is gonna be good to merge very soon!

src/command.rs Outdated
target,
crate_name: None,
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would like a line here :)

Copy link
Contributor Author

@kohensu kohensu Jun 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oups,
yes sure

src/command.rs Outdated
}
pub fn process(&mut self, log: &Logger) -> result::Result<(), Error> {
let steps: Vec<fn(&mut Init, &Step, &Logger) -> result::Result<(), Error>> =
if self.skip_build {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ugh GH didn't post this comment in my original review)

so- i think we might be exploring even more "build" modes (see #153 ) - so (and i am likely overengineering here) but perhaps an enum and a match statement would work best here. would love to hear your thoughts!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something like this ?

enum InitMode {
    Normal,
    Nobuild,
}

impl Init {
    pub fn process(&mut self, log: &Logger, mode: InitMode) -> result::Result<(), Error> {
        let steps: Vec<fn(&mut Init, &Step, &Logger) -> result::Result<(), Error>> =
            match mode {
                InitMode::Normal => vec![
                    Init::step_add_wasm_target,
                    ...
                ],
                InitMode::Nobuild => vec![
                    Init::step_create_dir,
                    ...
                ],
            };
        let mut step = Step::new(steps.len());
        ...
    }
}

pub fn run_wasm_pack(command: Command, log: &Logger) -> result::Result<(), Error> {
    let status = match command {
        Command::Init {
            path,
            scope,
            skip_build,
            disable_dts,
            target,
        } => {
            ...
            let mode = if skip_build {InitMode::Nobuild} else {InitMode::Normal};
            Init::new(path, scope, disable_dts, target).process(&log, mode)
        }
        ...
    };
    ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the modification this modification in the PR, if it is not like you what you had in mind I will revert it.

Copy link
Contributor

@mgattozzi mgattozzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never thought to make it a vector of functions. Honestly this is just a real clever PR and I really like it. My own nit is I don't think we need to rename every function to step_* but that's more of a personal preference and I'll defer to @ashleygwilliams on this! Seriously well done. Gonna have to test this out locally as well! :D

@ashleygwilliams ashleygwilliams added needs tests please add tests to this PR needs docs please add docs to this PR and removed needs review labels Jun 11, 2018
@ashleygwilliams
Copy link
Member

@kohensu super impressed with this- thanks so much! the only thing this needs is a test and some docs (a paragraph like the other flags in this doc: https://github.com/ashleygwilliams/wasm-pack/blob/master/docs/init.md). lemme know if you wanna do that or if you'd like some help!

@ashleygwilliams
Copy link
Member

also- just as a heads up we are probably landing 2 PRs today which means this will likely need a rebase, but i'd like to prioritize getting this in after that so that we don't have too much rebasing that needs to happen :)

@ashleygwilliams
Copy link
Member

lemme know if you want to tackle the rebase- otherwise i can do it!

@kohensu
Copy link
Contributor Author

kohensu commented Jun 13, 2018

ok, I will do the rebase, the test and the doc

@kohensu kohensu force-pushed the add_--skip-build_flag_#144 branch from 1576fc1 to c3cc16b Compare June 13, 2018 09:05
This flag skips:
    adding target
    compiling to wasm
    installing wasm-bindgen
    running wasm-bindgen
Copy link
Contributor

@mgattozzi mgattozzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to say that this LGTM :) great job!

@ashleygwilliams ashleygwilliams removed needs docs please add docs to this PR needs rebase needs tests please add tests to this PR labels Jun 13, 2018
@ashleygwilliams ashleygwilliams merged commit 0c8c90a into rustwasm:master Jun 13, 2018
@kohensu kohensu deleted the add_--skip-build_flag_#144 branch June 13, 2018 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants