-
Notifications
You must be signed in to change notification settings - Fork 409
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
Improve UX for pack and publish path expectations #198
Conversation
src/command/pack.rs
Outdated
npm::npm_pack(&crate_path)?; | ||
match npm::npm_pack(&crate_path) { | ||
Ok(r) => r, | ||
Err(Error::Io { .. }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this match is too broad. I only want to catch os error 2: directory not found. I don't want to swallow other IO errors. Investigate how to do that.
src/command/pack.rs
Outdated
@@ -9,7 +9,15 @@ pub fn pack(path: Option<String>, log: &Logger) -> result::Result<(), Error> { | |||
let crate_path = set_crate_path(path); | |||
|
|||
info!(&log, "Packing up the npm package..."); | |||
npm::npm_pack(&crate_path)?; | |||
match npm::npm_pack(&crate_path) { | |||
Ok(r) => r, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably just be Ok(r) => (),
src/command/pack.rs
Outdated
Ok(r) => r, | ||
Err(Error::Io { .. }) => { | ||
return Err(Error::DirNotFound { | ||
message: "Unable to find the pkg directory".to_owned(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be more specific? Should it also print the path that the user entered? Not sure yet.
src/command/pack.rs
Outdated
message: "Unable to find the pkg directory".to_owned(), | ||
}); | ||
} | ||
Err(e) => return Err(e), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These explicit return
statements feel like code smells. Maybe I can use the ?
operator here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should try something like this instead:
my_function_call().map_err(|e| match {
interesting_error => something_else,
stuff => stuff,
})?
@mgattozzi could you give this a quick look? Am I on the right path? Also, how should I do with tests? I don't like shipping code without unit tests. It looks like I have to inject the The code is repeated between pack and publish. Do you believe it should be abstracted or do we keep it like this? |
This lets us have backwards compatibility while improving the user experience.
thanks so much for this @Mackiovello ! i'll give a review by EOD today :) |
This does not work as expected right now. I'll look at it later today. Don't review yet |
Never mind, it actually works. I was confused since I got
|
Ran
|
@ashleygwilliams this is ready for a review 🙂 |
hey @Mackiovello ! thanks so much for this. so far it looks great! do you think you could add some docs and perhaps a test (let me know if you run into trouble with this one)? since this is about expectations, i think some docs would be great :) should be close to getting this in tho- thanks so much again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs docs and a test! once that's done i'm happy to merge
Thank you @ashleygwilliams! One question: Where do you want documentation? On the Also, should the tests be unit tests with no access to the file system or should it be integration tests that are allowed to use the file system? I think it should be fine with unit tests, but then I have to inject functions like |
@Mackiovello so- for the docs, i would add both API docs (not too specific to end user, just add descriptions of the functionality generally), and then and more user-facing specific docs to the docs in the for the tests, all our tests currently use the filesystem by accessing code in the lemme know if you have any other questions. |
90c3fec
to
88fdbc5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so i'm pretty sure this is failing because it needs a rebase to include #214. this is approved, i'm goona do the rebase and hopefully get this in today! THANK YOU SO MUCH!!
Okay, I have to take this piece by piece. I'm creating this as a WIP pull request to some pressure on myself but also to make it easier to ask for help.
If anyone sees anything that can be improved or think should be changed, please tell me. I'm new to Rust, so every little hint helps. I'll put some questions in my own code for my own reference but also for you to answer if you have time.
This is for #189
saving this for later
Make sure these boxes are checked! 📦✅
rustfmt
installed and have yourcloned directory set to nightly
$ rustup override set nightly $ rustup component add rustfmt-preview --toolchain nightly
rustfmt
on the code base before submitting✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨