fix: remove pnpm-specific options before calling npm publish#10077
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes warnings that occur when running pnpm publish with pnpm-specific CLI options by filtering out options that npm doesn't recognize before passing them to the underlying npm publish command.
- Replaces inline
--publish-branchremoval logic with a comprehensive function that handles multiple pnpm-specific options - Adds support for filtering additional options like
--no-git-checks,--npm-path, and embed-readme related flags - Includes comprehensive test coverage for the new filtering functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| releasing/plugin-commands-publishing/src/publish.ts | Implements removePnpmSpecificOptions function and replaces inline option filtering |
| releasing/plugin-commands-publishing/test/removePnpmSpecificOptions.test.ts | Adds comprehensive test suite for the new option filtering function |
| .changeset/fix-git-checks-warning.md | Documents the fix for issue #9646 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Skip the option itself | ||
| i++ | ||
| // Skip its value if the next arg exists and doesn't look like an option | ||
| if (i < args.length && args[i][0] !== '-') { |
There was a problem hiding this comment.
The check args[i][0] !== '-' will throw an error if args[i] is an empty string. Add a length check: args[i].length > 0 && args[i][0] !== '-'.
| if (i < args.length && args[i][0] !== '-') { | |
| if (i < args.length && args[i].length > 0 && args[i][0] !== '-') { |
| const pnpmOnlyOptions = new Set([ | ||
| '--publish-branch', | ||
| '--no-git-checks', | ||
| '--npm-path', | ||
| '--embed-readme', | ||
| '--no-embed-readme', | ||
| ]) |
There was a problem hiding this comment.
some of these are booleans that don't have a value. As a result, something like this will break:
pnpm publish --no-git-checks ./tarball-name.tgz
There was a problem hiding this comment.
Thanks, fixed it.
fix: distinguish boolean and value options when filtering
Fixes #9646
Fixed warnings when running
pnpm publishwith pnpm-specific options like--no-git-checks.