Repository navigation
fix(npm): return the real value for info field; name the missing program - #1200
Merged
Merged
Conversation
…ogram
`npm view <pkg> <field> --json` prints a bare value ("2.0.8", an object, or
nothing), and parseInfoJson read name/version off it, falling back to
"unknown"/"0.0.0" (#1164).
- With `field`, info returns { name, field, value }; value is omitted when
the package does not set the field. version/description are optional.
- parseInfoJson rejects output that is not a JSON object instead of filling
placeholders.
- Smoke S9 mocked a full metadata object for a field query; it now uses
npm's real output.
shared: when cmd.exe reports "'x' is not recognized" for a .cmd wrapper and
x is not the wrapper, the error names x and the wrapper that needed it. This
came out of #1093, which does not reproduce on current code.
Fixes #1164
Refs #1093
horza-bora
approved these changes
Oct 19, 2026
horza-bora
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed: info field returns the real value (verified old vs new end to end), placeholders rejected, clearer not-found message with a Windows test. CI green.
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.
What changed
#1164:
infowithfield.npm view <pkg> <field> --jsonprints only that field's value:"2.0.8", an object, or nothing at all.parseInfoJsonreadnameandversionoff that value and fell back to"unknown"/"0.0.0". So an agent asking for the latest version got a confident wrong answer.field, the result is now{ name, field, value }.valueis omitted when the package doesn't set the field, andversion/descriptionare now optional in the schema.parseInfoJsonthrows on output that isn't a JSON object, instead of filling in placeholders.#1093 diagnostics. When cmd.exe reports
'x' is not recognizedwhile running a.cmdwrapper, andxisn't the wrapper itself, the error now namesxand the wrapper that needed it. #1093 itself doesn't reproduce on current code (details on the issue), so this PR only refers to it.Fixes #1164. Refs #1093.
How it was tested
proxy-addr:versiongives"2.0.8",enginesgives an object, and a nonexistent field gives nothing.info proxy-addrwith fieldsversion,enginesandfunding. The Aug 19 build returns{name:"unknown",version:"0.0.0"}for all three. This branch returns the real values, e.g.{name:"proxy-addr",field:"engines",value:{node:">= 0.10"}}.info-search.test.ts35 of 35 (5 new). Sharedrunner.test.ts95 of 95, plus a new Windows test for the message. Smoke 2337 of 2337. tsc, eslint and prettier are clean.