Skip to content

Commit

Permalink
fix(release): catch ownership error
Browse files Browse the repository at this point in the history
  • Loading branch information
chnliquan committed Sep 20, 2022
1 parent 8a293af commit 3d18e66
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/release/src/core/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ async function ownershipCheck(publishPkgNames: string[]) {
step('Checking npm ownership ...')

const whoami = (await run('npm whoami')).stdout.trim()
await Promise.all(
publishPkgNames.map(async pkgName => {

for (const pkgName of publishPkgNames) {
try {
const owners = (await run(`npm owner ls ${pkgName}`)).stdout
.trim()
.split('\n')
Expand All @@ -309,8 +310,15 @@ async function ownershipCheck(publishPkgNames: string[]) {
if (!owners.includes(whoami)) {
logger.printErrorAndExit(`${pkgName} is not owned by ${whoami}.`)
}
}),
)
} catch (err) {
if ((err as Error).message.indexOf('Not Found') > -1) {
continue
}

logger.error(`${pkgName} ownership is invalid.`)
throw new Error((err as Error).message)
}
}
}

async function reconfirm(targetVersion: string, publishPkgNames: string[]) {
Expand Down

0 comments on commit 3d18e66

Please # to comment.