Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 59ab9ef

Browse files
committed
fix: Add ensureConfigDependencies to fix test
1 parent 6579d10 commit 59ab9ef

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/project-manager.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export class ProjectManager implements Disposable {
321321
span.addTags({ uri, maxDepth });
322322
ignore.add(uri);
323323
return this.ensureModuleStructure(span)
324+
.concat(Observable.defer(() => this.ensureConfigDependencies()))
324325
// If max depth was reached, don't go any further
325326
.concat(Observable.defer(() => maxDepth === 0 ? Observable.empty<never>() : this.resolveReferencedFiles(uri)))
326327
// Prevent cycles
@@ -337,6 +338,24 @@ export class ProjectManager implements Disposable {
337338
});
338339
}
339340

341+
isConfigDependency(uri: string): boolean {
342+
for (const config of this.configurations()) {
343+
config.ensureConfigFile();
344+
if (config.isExpectedDeclarationFile(uri)) {
345+
return true;
346+
}
347+
}
348+
return false;
349+
}
350+
351+
ensureConfigDependencies(): Observable<never> {
352+
return observableFromIterable(this.inMemoryFs.uris())
353+
.filter(uri => this.isConfigDependency(uri2path(uri)))
354+
.mergeMap(uri => this.updater.ensure(uri))
355+
.publishReplay()
356+
.refCount();
357+
}
358+
340359
/**
341360
* Invalidates a cache entry for `resolveReferencedFiles` (e.g. because the file changed)
342361
*
@@ -877,7 +896,7 @@ export class ProjectConfiguration {
877896
* [isExpectedDeclarationFile description]
878897
* @param {string} fileName [description]
879898
*/
880-
private isExpectedDeclarationFile(fileName: string) {
899+
public isExpectedDeclarationFile(fileName: string) {
881900
if (isDeclarationFile(fileName)) {
882901
return this.expectedFilePaths.has(toUnixPath(fileName)) ||
883902
this.typeRoots.some(root => fileName.startsWith(root));

src/test/project-manager.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ describe('ProjectManager', () => {
3939
});
4040
it('loads files from typeRoots', async () => {
4141
await projectManager.ensureReferencedFiles('file:///project/file.ts').toPromise();
42-
projectManager.invalidateModuleStructure();
43-
await projectManager.ensureModuleStructure().toPromise();
4442
memfs.getContent('file:///project/file.ts');
4543
memfs.getContent('file:///types/types.d.ts');
4644
});

0 commit comments

Comments
 (0)