feat: implement gitSubdir according to npa spec#442
Open
Conversation
wraithgar
reviewed
Feb 3, 2026
| resolved: this.resolved, | ||
| integrity: null, // it'll always be different, if we have one | ||
| }).extract(tmp).then(() => handler(tmp), er => { | ||
| }).extract(tmp).then(() => handler(`${tmp}${this.spec.gitSubdir || ''}`), er => { |
Member
There was a problem hiding this comment.
This is not going to work in windows, right? I suspect this is the case especially given that you bypassed testing in windows itself. A feature like this has to work in all operating systems.
Author
There was a problem hiding this comment.
Hi, thank you very much for taking a look!
Initially, I added the test exclusion on windows, because all other git tests are also skipped with that exact expression. Earlier in the test file, there is a comment about problems with PromiseSpawn on windows.
To be on the safe side, I just tested this under windows and everything works on my device. Just for "fun", I tested in a MacOS VM - it seems to work fine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 implements the
gitSubdirparameter, which is already parsed by npa, finally allowing users of npm to specifiy subdirectories in git dependencies.The respective parsing logic has already been agreed on and implemented nearly 4 years ago here: npm/npm-package-arg#91. In this PR, the git fetcher is changed to resolve the
gitSubdirparameter from the spec if found, as suggested by the author in the original npa PR.References
Fixes npm/cli#528
Fixes npm/npm#2974
Relates to npm/npm-package-arg#46
Relates to npm/npm-package-arg#91
Inspired from and crediting sspiff@8bd5461, which seems to have been lost after merging the PR at npa.