-
-
Notifications
You must be signed in to change notification settings - Fork 302
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 --branch
flag for specifying default branch
#476
Add --branch
flag for specifying default branch
#476
Conversation
--default-branch
flag for specifying default branch
@hewIngram Thanks for the PR, it looks great! |
Thanks for the comments both and sorry for the delay. Have made the above changes. I don't think he description in |
@@ -43,6 +44,10 @@ const cli = meow(` | |||
anyBranch: { | |||
type: 'boolean' | |||
}, | |||
defaultBranch: { |
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.
defaultBranch: { | |
branch: { |
@@ -38,8 +38,8 @@ exports.currentBranch = async () => { | |||
return stdout; | |||
}; | |||
|
|||
exports.verifyCurrentBranchIsMaster = async () => { | |||
if (await exports.currentBranch() !== 'master') { | |||
exports.verifyCurrentBranchIsDefault = async (defaultBranch = 'master') => { |
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.
No need to define a default value here, as it's set by meow
(see this line).
exports.verifyCurrentBranchIsMaster = async () => { | ||
if (await exports.currentBranch() !== 'master') { | ||
exports.verifyCurrentBranchIsDefault = async (defaultBranch = 'master') => { | ||
if (await exports.currentBranch() !== defaultBranch) { | ||
throw new Error('Not on `master` branch. Use --any-branch to publish anyway.'); |
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.
throw new Error('Not on `master` branch. Use --any-branch to publish anyway.'); | |
throw new Error(`Not on \`{defaultBranch}\` branch. Use --any-branch to publish anyway, or define a different default branch using --branch.`); |
await t.throwsAsync(gitUtil.verifyCurrentBranchIsDefault); | ||
}); | ||
|
||
test('verifyCurrentBranchIsDefault doesn\'t throw if current branch the specified default branch', async t => { |
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.
test('verifyCurrentBranchIsDefault doesn\'t throw if current branch the specified default branch', async t => { | |
test('verifyCurrentBranchIsDefault doesn\'t throw if current branch is the specified default branch', async t => { |
Thanks @hewIngram! I left a few final comments, but overall this is almost ready to be merged 👌🏻 |
--default-branch
flag for specifying default branch--branch
flag for specifying default branch
#476 (comment) still needs to be resolved. |
You also need to document it in the config section: https://github.com/sindresorhus/np#config |
@hewIngram Bump :) |
I created a pull request for the work done this pull request, it fixes the open documentation issues. I hope this will get merged into the project ASAP |
@dadadidudu Can you submit a PR here with the commits in this PR and also your additions? Doesn't look like hewIngram#1 will be merged. |
Closing this PR for lack of activity. |
Fixes: #466
Tweaks the
verifyCurrentBranchIsMaster
function to allow users to pass in a custom default branch name and restrict publishing to that branch only.Question:
Do we want to default
--any-branch
on if users set--default-branch
or is there another reason they might set one without the other?I'm not familiar with Ava - is there a way to group tests like a describe block to group these
verifyCurrentBranchIsDefault
tests?