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

Function searchForPackageRoot

packages/vite/src/node/server/searchRoot.ts:68–79  ·  view source on GitHub ↗
(
  current: string,
  root: string = current,
)

Source from the content-addressed store, hash-verified

66 * Search up for the nearest `package.json`
67 */
68export function searchForPackageRoot(
69 current: string,
70 root: string = current,
71): string {
72 if (hasPackageJSON(current)) return current
73
74 const dir = dirname(current)
75 // reach the fs root
76 if (!dir || dir === current) return root
77
78 return searchForPackageRoot(dir, root)
79}
80
81/**
82 * Search up for the nearest workspace root

Callers 2

resolveServerOptionsFunction · 0.90
searchForWorkspaceRootFunction · 0.85

Calls 1

hasPackageJSONFunction · 0.85

Tested by

no test coverage detected