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

Function findNearestNodeModules

packages/vite/src/node/packages.ts:239–252  ·  view source on GitHub ↗
(basedir: string)

Source from the content-addressed store, hash-verified

237}
238
239export function findNearestNodeModules(basedir: string): string | null {
240 while (basedir) {
241 const pkgPath = path.join(basedir, 'node_modules')
242 if (tryStatSync(pkgPath)?.isDirectory()) {
243 return pkgPath
244 }
245
246 const nextBasedir = path.dirname(basedir)
247 if (nextBasedir === basedir) break
248 basedir = nextBasedir
249 }
250
251 return null
252}
253
254export function watchPackageDataPlugin(packageCache: PackageCache): Plugin {
255 // a list of files to watch before the plugin is ready

Callers 1

Calls 1

tryStatSyncFunction · 0.90

Tested by

no test coverage detected