fix: show full parent command path in subcommand usage errors#9404
Open
shaanmajid wants to merge 2 commits into
Open
fix: show full parent command path in subcommand usage errors#9404shaanmajid wants to merge 2 commits into
shaanmajid wants to merge 2 commits into
Conversation
|
Tested this locally and can confirm it works. Ran the test suite and everything passes:
The fix does what it's supposed to - error messages now show the full command path like "npm stage approve " instead of the broken "npm approve ". Verified it works for both stage and trust subcommands. Code looks solid, no edge cases I can find, and there's good test coverage. Ready to ship acc. to me! |
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.
Summary
npm stage approvewithout a<stage-id>) rendered the bare subcommand name (e.g.,npm approve <stage-id>) andRun "npm help approve" for more info-- pointing at a command and help page that don't exist.usageErrorrender the full path (npm stage approve <stage-id>) and point to the real help page (npm help stage)This fix applies to
npm stageandnpm trust.Implementation
lib/npm.js: setparentNameon the subcommand instance during dispatch (and use the full joined path on the--helpbranch for parity).lib/base-cmd.js: the instanceusagegetter threadsparentNameintogetUsage, and the help footer resolves to the top-level documented command.References
Fixes #9403