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

feat: threw error if profile-create-new-if-missing used without profile #2073

Conversation

akhilpanchal
Copy link
Contributor

Follow up to #2064 based on @rpl's comment.

Throws error if profile-create-new-if-missing option used without firefox-profile or chromium-profile.

@coveralls
Copy link

coveralls commented Nov 15, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 5b8dfdc on akhilpanchal:throw-if-profile-create-new-used-without-profile into 294428c on mozilla:master.

@rpl rpl self-requested a review November 17, 2020 14:50
Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

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

@akhilpanchal Thanks for looking into quickly jumping on covering the followups related to #2064!!!
Follows a couple of review comments.

src/cmd/run.js Outdated
Comment on lines 135 to 139
} else if (profileCreateIfMissing) {
throw new UsageError(
'--profile-create-if-missing should be paired ' +
'with --firefox-profile or --chromium-profile'
);
Copy link
Member

Choose a reason for hiding this comment

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

we could move this into the previous if block by doing something like:

if (profileCreateIfMissing) {
  if (!profileDir) {
    throw new UsageError("...);
  }
  // the rest of the if block from line 128 to line 133.
}

Comment on lines 415 to 426
let actualError = null;
try {
await cmd.run({ profileCreateIfMissing: true });
} catch (error) {
actualError = error;
}

assert.instanceOf(actualError, UsageError);
assert.match(
actualError && actualError.message,
/should be paired with --firefox-profile or --chromium-profile/
);
Copy link
Member

Choose a reason for hiding this comment

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

we should use await assert.isRejected(...) (provided by the chai-as-promised dev dependency and also used in some of the other tests, e.g. test.adb.js should be one of the test file already using this assertion functions).

@akhilpanchal
Copy link
Contributor Author

akhilpanchal commented Nov 19, 2020

@akhilpanchal Thanks for looking into quickly jumping on covering the followups related to #2064!!!
Follows a couple of review comments.

Thanks @rpl. I addressed your feedback in the latest commit.
I also have a pull request open in the extension-workshop repo for documenting this option.
Let me know if you have any feedback for me.

Thanks again for all your guidance and comments 😊

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

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

@akhilpanchal good job, this looks great. I would just tweak the UsageError message a bit (my apologies I should have noticed it sooner and pointed it out in the previous review round) before merging this on master, would you mind to do that? (the tweak is described below).

src/cmd/run.js Outdated
if (profileCreateIfMissing) {
if (!profileDir) {
throw new UsageError(
'--profile-create-if-missing should be paired ' +
Copy link
Member

Choose a reason for hiding this comment

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

would you mind to replace should be paired with with requires? (mostly because I'm not really sure if paired is a common why to refer to that in english, "--profile-create-if-missing requires --firefox-profile or --chromium-profile" is shorter and should be clear enough).

Same change has to be applied to the assertion on the test side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@akhilpanchal good job, this looks great. I would just tweak the UsageError message a bit (my apologies I should have noticed it sooner and pointed it out in the previous review round) before merging this on master, would you mind to do that? (the tweak is described below).

No worries at all! Makes sense to me. It is shorter and clear.
I addressed it.

@rpl
Copy link
Member

rpl commented Nov 19, 2020

@akhilpanchal Thanks a lot! looks great and I'm going to merge it right now! 🎉

@rpl rpl merged commit 7e5ffcb into mozilla:master Nov 19, 2020
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