@@ -9,7 +9,7 @@ import { FileLoader, LoadFile } from './loader'
99import { JsonSourceFile } from './json-source-file'
1010import { JsonTextSourceFile } from './json-text-source-file'
1111import { LookupContext } from './lookup'
12- import { walkUp , WalkUpOptions } from './walk'
12+ import { lineage , LineageOptions } from './walk'
1313import { Workspace } from './workspace'
1414
1515class PackageFilesCache {
@@ -189,24 +189,15 @@ export class PackageFilesResolver {
189189 this . workspace = workspace
190190 }
191191
192- async loadPackageJsonFile ( filePath : string , options ?: WalkUpOptions ) : Promise < PackageJsonFile | undefined > {
193- let packageJson : PackageJsonFile | undefined
194-
195- await walkUp ( filePath , async dirPath => {
196- packageJson = await this . cache . packageJson ( PackageJsonFile . filePath ( dirPath ) )
197- return packageJson !== undefined
198- } , options )
199-
200- return packageJson
201- }
202-
203- async loadPackageFiles ( filePath : string , options ?: WalkUpOptions ) : Promise < PackageFiles > {
192+ async loadPackageFiles ( filePath : string , options ?: LineageOptions ) : Promise < PackageFiles > {
204193 const files = new PackageFiles ( )
205194
206- await walkUp ( filePath , async dirPath => {
207- const found = await files . satisfyFromDirPath ( dirPath , this . cache )
208- return found
209- } , options )
195+ for ( const searchPath of lineage ( path . dirname ( filePath ) , options ) ) {
196+ const found = await files . satisfyFromDirPath ( searchPath , this . cache )
197+ if ( found ) {
198+ break
199+ }
200+ }
210201
211202 return files
212203 }
0 commit comments