MCPcopy
hub / github.com/vitejs/vite / findNearestMainPackageData

Function findNearestMainPackageData

packages/vite/src/node/packages.ts:162–176  ·  view source on GitHub ↗
(
  basedir: string,
  packageCache?: PackageCache,
)

Source from the content-addressed store, hash-verified

160
161// Finds the nearest package.json with a `name` field
162export function findNearestMainPackageData(
163 basedir: string,
164 packageCache?: PackageCache,
165): PackageData | null {
166 const nearestPackage = findNearestPackageData(basedir, packageCache)
167 return (
168 nearestPackage &&
169 (nearestPackage.data.name
170 ? nearestPackage
171 : findNearestMainPackageData(
172 path.dirname(nearestPackage.dir),
173 packageCache,
174 ))
175 )
176}
177
178export function loadPackageData(pkgPath: string): PackageData {
179 const data = JSON.parse(stripBomTag(fs.readFileSync(pkgPath, 'utf-8')))

Callers 4

resolveLibFilenameFunction · 0.90
generateBundleFunction · 0.90
tryNodeResolveFunction · 0.90
resolveLibCssFilenameFunction · 0.90

Calls 1

findNearestPackageDataFunction · 0.85

Tested by

no test coverage detected