Skip to content

fix: do not unwrap single-item arrays in --json output#9160

Open
yetanotheraryan wants to merge 1 commit intonpm:latestfrom
yetanotheraryan:json-unwrap-fix
Open

fix: do not unwrap single-item arrays in --json output#9160
yetanotheraryan wants to merge 1 commit intonpm:latestfrom
yetanotheraryan:json-unwrap-fix

Conversation

@yetanotheraryan
Copy link
Copy Markdown

@yetanotheraryan yetanotheraryan commented Mar 29, 2026

Fixes npm view --json returning a single object/value when a semver range matches exactly one version.

This change preserves top-level array output for explicit semver range queries, while keeping the existing unwrapped behavior for exact version, tag, and default package lookups.
Regression tests were added to cover both full-package and single-field JSON output for the single-match range case.

References

Fixes npm/statusboard#1074
Related to npm/statusboard#1068

@yetanotheraryan
Copy link
Copy Markdown
Author

@wraithgar @owlstronaut I’ve opened a PR to address this : npm/statusboard#1068

The change ensures that --json output consistently returns arrays, even for single-item results.

Happy to make any adjustments if needed!

verified the same on local -
when only one version is returned and still the output is in array format.
existing working as ususal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dont unwrap any single item arrays in view --json

1 participant