Skip to content

Commit 8d611b7

Browse files
committed
refactor: remove weird walkUp helper in favor of the lineage helper
1 parent 6fbb3d4 commit 8d611b7

File tree

1 file changed

+8
-17
lines changed
  • packages/cli/src/services/check-parser/package-files

1 file changed

+8
-17
lines changed

packages/cli/src/services/check-parser/package-files/resolver.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { FileLoader, LoadFile } from './loader'
99
import { JsonSourceFile } from './json-source-file'
1010
import { JsonTextSourceFile } from './json-text-source-file'
1111
import { LookupContext } from './lookup'
12-
import { walkUp, WalkUpOptions } from './walk'
12+
import { lineage, LineageOptions } from './walk'
1313
import { Workspace } from './workspace'
1414

1515
class 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

Comments
 (0)