From f73eeac0677b3a977915bdf1be6b032f087fb2e1 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 18 Aug 2023 04:01:38 +0300 Subject: [PATCH] fix: pnpm why should work without package.json files (#6953) --- .changeset/heavy-bananas-protect.md | 5 +++++ reviewing/list/src/index.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/heavy-bananas-protect.md diff --git a/.changeset/heavy-bananas-protect.md b/.changeset/heavy-bananas-protect.md new file mode 100644 index 0000000000..54ad42b38e --- /dev/null +++ b/.changeset/heavy-bananas-protect.md @@ -0,0 +1,5 @@ +--- +"@pnpm/list": patch +--- + +Don't fail when no `package.json` is found. diff --git a/reviewing/list/src/index.ts b/reviewing/list/src/index.ts index 9577132539..65e9e047a9 100644 --- a/reviewing/list/src/index.ts +++ b/reviewing/list/src/index.ts @@ -1,5 +1,5 @@ import path from 'path' -import { readProjectManifestOnly } from '@pnpm/read-project-manifest' +import { safeReadProjectManifestOnly } from '@pnpm/read-project-manifest' import { type DependenciesField, type Registries } from '@pnpm/types' import { type PackageNode, buildDependenciesHierarchy, type DependenciesHierarchy } from '@pnpm/reviewing.dependencies-hierarchy' import { createPackagesSearcher } from './createPackagesSearcher' @@ -74,7 +74,7 @@ export async function searchForPackages ( modulesDir: opts.modulesDir, })) .map(async ([projectPath, buildDependenciesHierarchy]) => { - const entryPkg = await readProjectManifestOnly(projectPath) + const entryPkg = await safeReadProjectManifestOnly(projectPath) ?? {} return { name: entryPkg.name, version: entryPkg.version, @@ -149,7 +149,7 @@ export async function list ( }) ) .map(async ([projectPath, dependenciesHierarchy]) => { - const entryPkg = await readProjectManifestOnly(projectPath) + const entryPkg = await safeReadProjectManifestOnly(projectPath) ?? {} return { name: entryPkg.name, version: entryPkg.version,