File tree Expand file tree Collapse file tree
packages/jest-resolve/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ export function clearFsCache(): void {
1414 checkedPaths . clear ( ) ;
1515 checkedRealpathPaths . clear ( ) ;
1616 packageContents . clear ( ) ;
17- packageJsonInDir . clear ( ) ;
1817}
1918
2019enum IPathType {
@@ -89,22 +88,9 @@ export function readPackageCached(path: Config.Path): PkgJson {
8988 return result ;
9089}
9190
92- const packageJsonInDir = new Map < string , boolean > ( ) ;
93- function directoryHasPackageJson ( file : Config . Path ) : boolean {
94- let cachedValue = packageJsonInDir . get ( file ) ;
95-
96- if ( cachedValue != null ) {
97- return cachedValue ;
98- }
99-
100- cachedValue = fs . existsSync ( file ) ;
101-
102- packageJsonInDir . set ( file , cachedValue ) ;
103-
104- return cachedValue ;
105- }
106-
107- // adapted from https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js to use cached `fs.stat` calls
91+ // adapted from
92+ // https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js
93+ // to use cached `fs` calls
10894export function findClosestPackageJson (
10995 start : Config . Path ,
11096) : Config . Path | undefined {
@@ -115,7 +101,7 @@ export function findClosestPackageJson(
115101
116102 while ( true ) {
117103 const pkgJsonFile = resolve ( dir , './package.json' ) ;
118- const hasPackageJson = directoryHasPackageJson ( pkgJsonFile ) ;
104+ const hasPackageJson = isFile ( pkgJsonFile ) ;
119105
120106 if ( hasPackageJson ) {
121107 return pkgJsonFile ;
You can’t perform that action at this time.
0 commit comments