@@ -21,6 +21,15 @@ let defaultCacheDirectory = null;
2121const gunzip = promisify ( zlib . gunzip ) ;
2222const gzip = promisify ( zlib . gzip ) ;
2323
24+ const findRootPackageJSON = ( ) => {
25+ if ( module . findPackageJSON ) {
26+ return module . findPackageJSON ( ".." , __filename ) ;
27+ } else {
28+ // todo: remove this fallback when dropping support for Node.js < 22.14
29+ return findUpSync ( "package.json" ) ;
30+ }
31+ } ;
32+
2433/**
2534 * Read the contents from the compressed file.
2635 *
@@ -136,7 +145,7 @@ const handleCache = async function (directory, params) {
136145 `discarded cache file '${ file } ' due to changes in external dependencies` ,
137146 ) ;
138147 } catch {
139- // conitnue if cache can't be read
148+ // continue if cache can't be read
140149 logger . debug ( `discarded cache as it can not be read` ) ;
141150 }
142151
@@ -219,7 +228,7 @@ function findCacheDir(name) {
219228 if ( env . CACHE_DIR && ! [ "true" , "false" , "1" , "0" ] . includes ( env . CACHE_DIR ) ) {
220229 return path . join ( env . CACHE_DIR , name ) ;
221230 }
222- const rootPkgJSONPath = path . dirname ( findUpSync ( "package.json" ) ) ;
231+ const rootPkgJSONPath = path . dirname ( findRootPackageJSON ( ) ) ;
223232 if ( rootPkgJSONPath ) {
224233 return path . join ( rootPkgJSONPath , "node_modules" , ".cache" , name ) ;
225234 }
0 commit comments