fix: pnpm why should work without package.json files (#6953)

This commit is contained in:
Zoltan Kochan
2023-08-18 04:01:38 +03:00
committed by GitHub
parent 64bf3c860a
commit f73eeac067
2 changed files with 8 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/list": patch
---
Don't fail when no `package.json` is found.

View File

@@ -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,