Skip to content

Commit

Permalink
fix: --report-summary must be with -r
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjiaxuan committed Jan 17, 2024
1 parent eb40821 commit 2daf8b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,8 @@
"release": {
"commit": "Release: {r}"
}
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
}
}
33 changes: 3 additions & 30 deletions src/command/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,13 @@ import type { PublishOption } from '..'

const cwd = process.cwd()

const publishSummaryPath = path.join(cwd, 'pnpm-publish-summary.json')

async function tryReadFile(retryTimes = 3, interval = 100) {
let countTimes = 0

async function main() {
try {
countTimes++
return (await fs.readFile(publishSummaryPath)).toString()
}
catch (err: any) {
// eslint-disable-next-line ts/no-unsafe-member-access
if (err.code === 'ENOENT' && countTimes < retryTimes) {
await new Promise(r => setTimeout(r, interval))
return main()
}

setFailed(`Fail to read \`pnpm-publish-summary.json\` with ${err}.`)
}

return '{publishedPackages:[]}'
}

return main()
}

export async function publish(options: PublishOption) {
const $$ = $({ stdout: process.stdout })
const $$ = $({ stdio: 'inherit' })

const publishArgs = [options.recursive ? '-r' : '', '--no-git-checks', '--report-summary'].filter(Boolean)
await $$`pnpm publish ${publishArgs}`
await $$`pnpm publish -r --report-summary --no-git-checks`

if (options.syncCnpm) {
const summaryStr = await tryReadFile()
const summaryStr = await fs.readFile(path.join(cwd, 'pnpm-publish-summary.json'))
const summaryJson = JSON.parse(summaryStr.toString()) as {
publishedPackages: {
name: string
Expand Down

0 comments on commit 2daf8b2

Please sign in to comment.