diff --git a/.changeset/famous-tigers-protect.md b/.changeset/famous-tigers-protect.md new file mode 100644 index 0000000000..81843758e7 --- /dev/null +++ b/.changeset/famous-tigers-protect.md @@ -0,0 +1,7 @@ +--- +"@pnpm/plugin-commands-listing": patch +"@pnpm/list": patch +"pnpm": patch +--- + +Fix issue where `pnpm list --json pkg` shows `"private": false` for a private package [#8519](https://github.com/pnpm/pnpm/issues/8519). diff --git a/reviewing/list/src/index.ts b/reviewing/list/src/index.ts index 375a5ac3fe..2732dca225 100644 --- a/reviewing/list/src/index.ts +++ b/reviewing/list/src/index.ts @@ -87,6 +87,7 @@ export async function searchForPackages ( return { name: entryPkg.name, version: entryPkg.version, + private: entryPkg.private, path: projectPath, ...buildDependenciesHierarchy, diff --git a/reviewing/plugin-commands-listing/src/list.ts b/reviewing/plugin-commands-listing/src/list.ts index 2750fcae67..f060bfe032 100644 --- a/reviewing/plugin-commands-listing/src/list.ts +++ b/reviewing/plugin-commands-listing/src/list.ts @@ -133,6 +133,7 @@ export type ListCommandOptions = Pick { + test.each([ + [undefined, false], + [false, false], + [true, true], + ])('%s -> %s', async (given, expected) => { + prepare({ + name: 'root', + version: '0.0.0', + private: given, + }) + + const output = await list.handler({ + ...DEFAULT_OPTS, + dir: process.cwd(), + json: true, + }, ['root']) + + expect(JSON.parse(output)).toStrictEqual([{ + name: 'root', + version: '0.0.0', + private: expected, + path: expect.any(String), + }]) + }) +})