Fix for #338 - Handle unpublished packages on github package registry #469
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Seeing the issue referenced in #338.
When running
npm info pkgName --json
NPM returns the 'E404' JSON response the code is expecting. If the registry target is the Github package registry, the samenpm info
command returns just an empty string.https://github.com/atlassian/changesets/blob/d570a24740a374a9547dd7d931e6ac854e36a9fb/packages/cli/src/commands/publish/npm-utils.ts#L61
This code errors b/c it tries to parse an empty string. This PR just returns an error object similar to what NPM returns so that the publish command just sees it as an unpublished package.
I'm not super familiar with this repo, but this solution could be improved by checking the registry and only allowing empty responses to count as 404 for github packages. Unsure how to do that here.