mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-12 10:11:42 -04:00
5
.changeset/stale-comics-press.md
Normal file
5
.changeset/stale-comics-press.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-publishing": patch
|
||||
---
|
||||
|
||||
add 'main' to default publish branch
|
||||
@@ -102,18 +102,18 @@ export async function handler (
|
||||
hint: GIT_CHECKS_HINT,
|
||||
})
|
||||
}
|
||||
const branch = opts.publishBranch ?? 'master'
|
||||
const branches = opts.publishBranch ? [opts.publishBranch] : ['master', 'main']
|
||||
const currentBranch = await getCurrentBranch()
|
||||
if (currentBranch !== branch) {
|
||||
if (!branches.includes(currentBranch)) {
|
||||
const { confirm } = await prompt({
|
||||
message: `You're on branch "${currentBranch}" but your "publish-branch" is set to "${branch}". \
|
||||
message: `You're on branch "${currentBranch}" but your "publish-branch" is set to "${branches.join('|')}". \
|
||||
Do you want to continue?`,
|
||||
name: 'confirm',
|
||||
type: 'confirm',
|
||||
} as any) as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
|
||||
if (!confirm) {
|
||||
throw new PnpmError('GIT_NOT_CORRECT_BRANCH', `Branch is not on '${branch}'.`, {
|
||||
throw new PnpmError('GIT_NOT_CORRECT_BRANCH', `Branch is not on '${branches.join('|')}'.`, {
|
||||
hint: GIT_CHECKS_HINT,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ const CREDENTIALS = [
|
||||
`--//localhost:${REGISTRY_MOCK_PORT}/:email=foo@bar.net`,
|
||||
]
|
||||
|
||||
test('publish: fails git check if branch is not on master', async () => {
|
||||
test('publish: fails git check if branch is not on master or main', async () => {
|
||||
prepare({
|
||||
name: 'test-publish-package.json',
|
||||
version: '0.0.0',
|
||||
@@ -48,7 +48,7 @@ test('publish: fails git check if branch is not on master', async () => {
|
||||
dir: process.cwd(),
|
||||
}, [])
|
||||
).rejects.toThrow(
|
||||
new PnpmError('GIT_NOT_CORRECT_BRANCH', "Branch is not on 'master'.")
|
||||
new PnpmError('GIT_NOT_CORRECT_BRANCH', "Branch is not on 'master|main'.")
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user