Skip to content

Commit

Permalink
Only initialize ignorer when required
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichon-msft committed Aug 26, 2021
1 parent 9e2f410 commit c21927a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions apps/rush-lib/src/logic/ProjectChangeAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,21 @@ export class ProjectChangeAnalyzer {
return undefined;
}

const projectHashDeps: Map<string, Map<string, string>> = new Map<string, Map<string, string>>();
const projectHashDeps: Map<string, Map<string, string>> = new Map();

for (const project of this._rushConfiguration.projects) {
projectHashDeps.set(project.packageName, new Map());
}

// Sort each project folder into its own package deps hash
for (const [filePath, fileHash] of repoDeps) {
// findProjectForPosixRelativePath uses LookupByPath, for which lookups are O(K)
// K being the maximum folder depth of any project in rush.json (usually on the order of 3)
const owningProject: RushConfigurationProject | undefined =
this._rushConfiguration.findProjectForPosixRelativePath(filePath);

if (owningProject) {
let owningProjectHashDeps: Map<string, string> | undefined = projectHashDeps.get(
owningProject.packageName
);
if (!owningProjectHashDeps) {
owningProjectHashDeps = new Map<string, string>();
projectHashDeps.set(owningProject.packageName, owningProjectHashDeps);
}
const owningProjectHashDeps: Map<string, string> = projectHashDeps.get(owningProject.packageName)!;
owningProjectHashDeps.set(filePath, fileHash);
}
}
Expand Down Expand Up @@ -268,16 +267,15 @@ export class ProjectChangeAnalyzer {
private async _getIgnoreMatcherForProjectAsync(
project: RushConfigurationProject,
terminal: Terminal
): Promise<Ignore> {
): Promise<Ignore | undefined> {
const projectConfiguration: RushProjectConfiguration | undefined =
await RushProjectConfiguration.tryLoadForProjectAsync(project, undefined, terminal);
const ignoreMatcher: Ignore = ignore();

if (projectConfiguration && projectConfiguration.incrementalBuildIgnoredGlobs) {
const ignoreMatcher: Ignore = ignore();
ignoreMatcher.add(projectConfiguration.incrementalBuildIgnoredGlobs);
return ignoreMatcher;
}

return ignoreMatcher;
}

private _getRepoDeps(terminal: Terminal): Map<string, string> | undefined {
Expand Down

0 comments on commit c21927a

Please sign in to comment.