Skip to content

Commit ff1db15

Browse files
committed
Cache rush-project.json reads
1 parent c21927a commit ff1db15

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

apps/rush-lib/src/api/RushProjectConfiguration.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export class RushProjectConfiguration {
126126
}
127127
});
128128

129+
private static readonly _configCache: Map<RushConfigurationProject, RushProjectConfiguration | false> =
130+
new Map();
131+
129132
public readonly project: RushConfigurationProject;
130133

131134
/**
@@ -177,8 +180,17 @@ export class RushProjectConfiguration {
177180
public static async tryLoadForProjectAsync(
178181
project: RushConfigurationProject,
179182
repoCommandLineConfiguration: CommandLineConfiguration | undefined,
180-
terminal: Terminal
183+
terminal: Terminal,
184+
skipCache?: boolean
181185
): Promise<RushProjectConfiguration | undefined> {
186+
// false is a signal that the project config does not exist
187+
const cacheEntry: RushProjectConfiguration | false | undefined = skipCache
188+
? undefined
189+
: RushProjectConfiguration._configCache.get(project);
190+
if (cacheEntry !== undefined) {
191+
return cacheEntry || undefined;
192+
}
193+
182194
const rigConfig: RigConfig = await RigConfig.loadForProjectFolderAsync({
183195
projectFolderPath: project.projectFolder
184196
});
@@ -197,8 +209,11 @@ export class RushProjectConfiguration {
197209
repoCommandLineConfiguration,
198210
terminal
199211
);
200-
return new RushProjectConfiguration(project, rushProjectJson);
212+
const result: RushProjectConfiguration = new RushProjectConfiguration(project, rushProjectJson);
213+
RushProjectConfiguration._configCache.set(project, result);
214+
return result;
201215
} else {
216+
RushProjectConfiguration._configCache.set(project, false);
202217
return undefined;
203218
}
204219
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Cache rush-project.json reads",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush",
10+
"email": "[email protected]"
11+
}

0 commit comments

Comments
 (0)