* Get cached `findNearestPackageData` value based on `basedir`. When one is found, * and we've already traversed some directories between `basedir` and `originalBasedir`, * we cache the value for those in-between directories as well. * * This makes it so the fs is only read once for a shared `ba
( packageCache: PackageCache, basedir: string, originalBasedir: string, )
| 343 | * This makes it so the fs is only read once for a shared `basedir`. |
| 344 | */ |
| 345 | function getFnpdCache( |
| 346 | packageCache: PackageCache, |
| 347 | basedir: string, |
| 348 | originalBasedir: string, |
| 349 | ) { |
| 350 | const cacheKey = getFnpdCacheKey(basedir) |
| 351 | const pkgData = packageCache.get(cacheKey) |
| 352 | if (pkgData) { |
| 353 | traverseBetweenDirs(originalBasedir, basedir, (dir) => { |
| 354 | packageCache.set(getFnpdCacheKey(dir), pkgData) |
| 355 | }) |
| 356 | return pkgData |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | function setFnpdCache( |
| 361 | packageCache: PackageCache, |
no test coverage detected