diff --git a/packages/@angular/cli/models/config.ts b/packages/@angular/cli/models/config.ts index e856e3336ae7..ce30348ae169 100644 --- a/packages/@angular/cli/models/config.ts +++ b/packages/@angular/cli/models/config.ts @@ -17,6 +17,9 @@ function getUserHome() { } +const configCacheMap = new Map>(); + + export class CliConfig extends CliConfigBase { static configFilePath(projectPath?: string): string { // Find the configuration, either where specified, in the Angular CLI project @@ -36,6 +39,10 @@ export class CliConfig extends CliConfigBase { globalConfigPath = altGlobalConfigPath; } + if (configCacheMap.has(globalConfigPath)) { + return configCacheMap.get(globalConfigPath); + } + const cliConfig = CliConfigBase.fromConfigPath(globalConfigPath); const aliases = [ @@ -63,6 +70,7 @@ export class CliConfig extends CliConfigBase { `)); } + configCacheMap.set(globalConfigPath, cliConfig); return cliConfig; } @@ -71,6 +79,9 @@ export class CliConfig extends CliConfigBase { if (!configPath) { return null; } + if (configCacheMap.has(configPath)) { + return configCacheMap.get(configPath); + } let globalConfigPath = path.join(getUserHome(), CLI_CONFIG_FILE_NAME); const altGlobalConfigPath = path.join(getUserHome(), CLI_CONFIG_FILE_NAME_ALT); @@ -106,6 +117,7 @@ export class CliConfig extends CliConfigBase { `)); } + configCacheMap.set(configPath, cliConfig); return cliConfig as CliConfig; } }