Fix ability to clone scoped packages #19
Open
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.
This fixes a bug where attempting to clone public, scoped packages (e.g.
@kgryte/noop
) would error out.There are two issues here: 1) npm-fetch seems not to handle scoped packages well, %-encoding just the @. This leads to errors like:
I initially tried to update npm-fetch, but it hasn't been updated in a long time. The npm-registry-client it uses is ancient, but porting to a newer version isn't trivial since the API has changed, and I wasn't sure exactly how to update the callers to handle all cases properly.
So, I added a new alternative for npm-fetch, pacote, here instead. I make use of it conditionally, only for this case where npm-fetch fails. It'd clean things up to replace npm-fetch with pacote entirely, but I wasn't sure it covers all of the same use cases in the same way.
This also adds a test for the new functionality. Unfortunately, I couldn't get the tests to pass on master, and I don't have a lot of time to figure out why. So I blindly added a test for scoped clones, which I think should cover this case just fine.
Let me know if this passes muster, or if I'm barking up the wrong tree. Thanks!