Skip to content

Commit

Permalink
fix(publish): exit with non-zero code when publish tgz failed (#5667)
Browse files Browse the repository at this point in the history
close #5396
  • Loading branch information
await-ovo committed Nov 23, 2022
1 parent fec9e31 commit a2b4326
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/fluffy-insects-jump.md
@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-publishing": patch
"pnpm": patch
---

`pnpm publish <tarball path>` should exit with non-0 exit code when publish fails [#5396](https://github.com/pnpm/pnpm/issues/5396).
4 changes: 2 additions & 2 deletions releasing/plugin-commands-publishing/src/publish.ts
Expand Up @@ -162,8 +162,8 @@ Do you want to continue?`,
return
}
if ((params.length > 0) && params[0].endsWith('.tgz')) {
runNpm(opts.npmPath, ['publish', ...params])
return
const { status } = runNpm(opts.npmPath, ['publish', ...params])
return { exitCode: status ?? 0 }
}
const dirInParams = (params.length > 0) && params[0]
const dir = dirInParams || opts.dir || process.cwd()
Expand Down
18 changes: 18 additions & 0 deletions releasing/plugin-commands-publishing/test/publish.ts
Expand Up @@ -708,3 +708,21 @@ test('publish: with specified publish branch name', async () => {
publishBranch: branch,
}, [])
})

test('publish: exit with non-zero code when publish tgz', async () => {
prepare({
name: 'test-publish-package.json',
version: '0.0.2',
})

const result = await publish.handler({
...DEFAULT_OPTS,
argv: { original: ['publish', './non-exists.tgz', '--no-git-checks'] },
dir: process.cwd(),
gitChecks: false,

}, [
'./non-exists.tgz',
])
expect(result?.exitCode).not.toBe(0)
})

0 comments on commit a2b4326

Please sign in to comment.