Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular/cli): cache config by file path. #4902

Merged
merged 1 commit into from
Feb 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/@angular/cli/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function getUserHome() {
}


const configCacheMap = new Map<string, CliConfigBase<ConfigInterface>>();


export class CliConfig extends CliConfigBase<ConfigInterface> {
static configFilePath(projectPath?: string): string {
// Find the configuration, either where specified, in the Angular CLI project
Expand All @@ -36,6 +39,10 @@ export class CliConfig extends CliConfigBase<ConfigInterface> {
globalConfigPath = altGlobalConfigPath;
}

if (configCacheMap.has(globalConfigPath)) {
return configCacheMap.get(globalConfigPath);
}

const cliConfig = CliConfigBase.fromConfigPath<ConfigInterface>(globalConfigPath);

const aliases = [
Expand Down Expand Up @@ -63,6 +70,7 @@ export class CliConfig extends CliConfigBase<ConfigInterface> {
`));
}

configCacheMap.set(globalConfigPath, cliConfig);
return cliConfig;
}

Expand All @@ -71,6 +79,9 @@ export class CliConfig extends CliConfigBase<ConfigInterface> {
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);
Expand Down Expand Up @@ -106,6 +117,7 @@ export class CliConfig extends CliConfigBase<ConfigInterface> {
`));
}

configCacheMap.set(configPath, cliConfig);
return cliConfig as CliConfig;
}
}