mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
## Summary This PR continues the work from #22107 to fix the `--tolerate-republish` flag implementation in `bun publish`. ### Changes: - **Pre-check version existence**: Before attempting to publish with `--tolerate-republish`, check if the version already exists on the registry - **Improved version checking**: Use GET request to package endpoint instead of HEAD, then parse JSON response to check if specific version exists - **Correct output stream**: Output warning to stderr instead of stdout for consistency with test expectations - **Better error handling**: Update test to accept both 403 and 409 HTTP error codes for duplicate publish attempts ### Test fixes: The tests were failing because: 1. The mock registry returns 409 Conflict (not 403) for duplicate packages 2. The warning message wasn't appearing in stderr as expected 3. The version check was using HEAD request which doesn't reliably return version info ## Test plan - [x] Fixed failing tests for `--tolerate-republish` functionality - [x] Tests now properly handle both 403 and 409 error responses - [x] Warning messages appear correctly in stderr 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
This commit is contained in:
@@ -82,6 +82,16 @@ The `--dry-run` flag can be used to simulate the publish process without actuall
|
||||
$ bun publish --dry-run
|
||||
```
|
||||
|
||||
### `--tolerate-republish`
|
||||
|
||||
The `--tolerate-republish` flag makes `bun publish` exit with code 0 instead of code 1 when attempting to republish over an existing version number. This is useful in automated workflows where republishing the same version might occur and should not be treated as an error.
|
||||
|
||||
```sh
|
||||
$ bun publish --tolerate-republish
|
||||
```
|
||||
|
||||
Without this flag, attempting to publish a version that already exists will result in an error and exit code 1. With this flag, the command will exit successfully even when trying to republish an existing version.
|
||||
|
||||
### `--gzip-level`
|
||||
|
||||
Specify the level of gzip compression to use when packing the package. Only applies to `bun publish` without a tarball path argument. Values range from `0` to `9` (default is `9`).
|
||||
|
||||
Reference in New Issue
Block a user