From 6704ab2c8a025800d871571889466e06399bf6a2 Mon Sep 17 00:00:00 2001 From: Aryan Tiwari <53210551+yetanotheraryan@users.noreply.github.com> Date: Tue, 12 May 2026 20:10:31 +0530 Subject: [PATCH 1/2] docs: npm view with json outputs array docs update (#9335) The --json flag for npm view now always returns an array, even when only a single version matches. Previously, a single item result would be unwrapped and returned as a plain object/string, which made programmatic parsing fragile - consumers had to handle both array and non-array shapes depending on how many versions matched. This doc update adds a note to npm-view.md clarifying that the output is always an array when --json is used, reflecting the behavioral fix. ## References Related to https://github.com/npm/statusboard/issues/1074#issuecomment-4372665984 --- docs/lib/content/commands/npm-view.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/lib/content/commands/npm-view.md b/docs/lib/content/commands/npm-view.md index 32838a0cdf692..36b8b93c0ddc1 100644 --- a/docs/lib/content/commands/npm-view.md +++ b/docs/lib/content/commands/npm-view.md @@ -174,6 +174,7 @@ If only a single string field for a single version is output, then it will not b If the field is an object, it will be output as a JavaScript object literal. If the `--json` flag is given, the outputted fields will be JSON. +The output is always an array, even if only a single version matches. If the version range matches multiple versions then each printed value will be prefixed with the version it applies to. From b61281da2d4e0a60a93f7138392bfc5893595705 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 12 May 2026 11:49:32 -0700 Subject: [PATCH 2/2] chore: change test wording to not collide with tap (#9349) --- workspaces/arborist/tap-snapshots/test/edge.js.test.cjs | 6 +++--- workspaces/arborist/test/edge.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/workspaces/arborist/tap-snapshots/test/edge.js.test.cjs b/workspaces/arborist/tap-snapshots/test/edge.js.test.cjs index 7b28779165d56..70be4d7566d86 100644 --- a/workspaces/arborist/tap-snapshots/test/edge.js.test.cjs +++ b/workspaces/arborist/tap-snapshots/test/edge.js.test.cjs @@ -758,7 +758,7 @@ Edge { } ` -exports[`test/edge.js TAP > peer dep at top level, nesting is ok 1`] = ` +exports[`test/edge.js TAP > peer dep at top level, nesting allowed 1`] = ` Edge { "dev": false, "error": null, @@ -863,7 +863,7 @@ Edge { } ` -exports[`test/edge.js TAP > peer dep below top level, nesting not ok 1`] = ` +exports[`test/edge.js TAP > peer dep below top level, nesting disallowed 1`] = ` Edge { "dev": false, "error": "PEER LOCAL", @@ -1032,7 +1032,7 @@ Edge { } ` -exports[`test/edge.js TAP > peer dep below top level, parallel ok 1`] = ` +exports[`test/edge.js TAP > peer dep below top level, parallel allowed 1`] = ` Edge { "dev": false, "error": null, diff --git a/workspaces/arborist/test/edge.js b/workspaces/arborist/test/edge.js index c9e6dc67d8849..f5ea071553195 100644 --- a/workspaces/arborist/test/edge.js +++ b/workspaces/arborist/test/edge.js @@ -198,7 +198,7 @@ t.matchSnapshot(new Edge({ type: 'peer', name: 'a', spec: '1.2.3', -}), 'peer dep at top level, nesting is ok') +}), 'peer dep at top level, nesting allowed') reset(top) reset(a) @@ -215,7 +215,7 @@ t.matchSnapshot(new Edge({ type: 'peer', name: 'aa', spec: '1.2.3', -}), 'peer dep below top level, nesting not ok') +}), 'peer dep below top level, nesting disallowed') reset(a) reset(aa) @@ -224,7 +224,7 @@ t.matchSnapshot(new Edge({ type: 'peer', name: 'b', spec: '1.2.3', -}), 'peer dep below top level, parallel ok') +}), 'peer dep below top level, parallel allowed') reset(a) reset(b)