* Get cached `resolvePackageData` 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 `basedi
( packageCache: PackageCache, pkgName: string, basedir: string, originalBasedir: string, preserveSymlinks: boolean, )
| 296 | * This makes it so the fs is only read once for a shared `basedir`. |
| 297 | */ |
| 298 | function getRpdCache( |
| 299 | packageCache: PackageCache, |
| 300 | pkgName: string, |
| 301 | basedir: string, |
| 302 | originalBasedir: string, |
| 303 | preserveSymlinks: boolean, |
| 304 | ) { |
| 305 | const cacheKey = getRpdCacheKey(pkgName, basedir, preserveSymlinks) |
| 306 | const pkgData = packageCache.get(cacheKey) |
| 307 | if (pkgData) { |
| 308 | traverseBetweenDirs(originalBasedir, basedir, (dir) => { |
| 309 | packageCache.set(getRpdCacheKey(pkgName, dir, preserveSymlinks), pkgData) |
| 310 | }) |
| 311 | return pkgData |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | function setRpdCache( |
| 316 | packageCache: PackageCache, |
no test coverage detected