Fix package.json hover metadata broken in npm 12+ - #327951
Merged
Martin Aeschlimann (aeschli) merged 2 commits intoAug 19, 2026
Merged
Conversation
Copilot started reviewing on behalf of
Guilherme Menezes Magalhães (guimmd2)
July 29, 2026 03:19
View session
Collaborator
|
Guilherme Menezes Magalhães (@guimmd2) Can we add a test for the fix? |
Contributor
Author
|
@microsoft-github-policy-service agree |
Guilherme Menezes Magalhães (guimmd2)
force-pushed
the
fix/npm12-view-array
branch
from
August 17, 2026 21:43
7060e11 to
300f55e
Compare
Contributor
Author
Hey Dmitriy Vasyura (@dmitrivMS), sure. The extension didn't have a test suite, so I created one and added some tests to cover this fix and the overall npm view functionality. Thanks for checking the PR. |
Guilherme Menezes Magalhães (guimmd2)
force-pushed
the
fix/npm12-view-array
branch
from
August 17, 2026 21:49
300f55e to
7060e11
Compare
npm 12 changed npm view --json to always return an array [{...}]
instead of {...}. Handle both formats by checking Array.isArray.
Fixes #327228
Move the `npm view --json` parsing out of `npmView()` into a pure `parseNpmViewOutput()` function so the npm 12+ array-format fix can be unit tested without the vscode API. Add a mocha suite covering object and array output, dist-tags.latest preference and fallback, missing fields, invalid and non-object output, and register the npm extension in .vscode-test.js so CI runs the tests.
Guilherme Menezes Magalhães (guimmd2)
force-pushed
the
fix/npm12-view-array
branch
from
August 17, 2026 21:49
7060e11 to
f7758b9
Compare
Martin Aeschlimann (aeschli)
enabled auto-merge (squash)
August 19, 2026 09:26
Martin Aeschlimann (aeschli)
approved these changes
Aug 19, 2026
Dmitriy Vasyura (dmitrivMS)
approved these changes
Aug 19, 2026
Ulugbek Abdullaev (ulugbekna)
approved these changes
Aug 19, 2026
Martin Aeschlimann (aeschli)
merged commit Aug 19, 2026
716116e
into
microsoft:main
27 of 29 checks passed
Dileep Yavanmandha (dileepyavan)
pushed a commit
that referenced
this pull request
Aug 19, 2026
* Fix npm view --json returning array in npm 12+
npm 12 changed npm view --json to always return an array [{...}]
instead of {...}. Handle both formats by checking Array.isArray.
Fixes #327228
* Extract npm view output parsing into a testable module with tests
Move the `npm view --json` parsing out of `npmView()` into a pure
`parseNpmViewOutput()` function so the npm 12+ array-format fix can be
unit tested without the vscode API. Add a mocha suite covering object
and array output, dist-tags.latest preference and fallback, missing
fields, invalid and non-object output, and register the npm extension
in .vscode-test.js so CI runs the tests.
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.
Fixes #327228
Description
npm 12 changed npm view --json to always return an array [{...}] instead of {...}. Handle both formats by checking Array.isArray.
Validation
Both versions work after the fix.