Skip to content

Commit

Permalink
feat(settings): allow project local settings with cdk.local.json
Browse files Browse the repository at this point in the history
  • Loading branch information
kornicameister committed Apr 12, 2024
1 parent 8198884 commit e4187d5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/aws-cdk/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as util from './util';
export type SettingsMap = {[key: string]: any};

export const PROJECT_CONFIG = 'cdk.json';
export const PROJECT_LOCAL_CONFIG = 'cdk.local.json';
export const PROJECT_CONTEXT = 'cdk.context.json';
export const USER_DEFAULTS = '~/.cdk.json';

Expand Down Expand Up @@ -111,6 +112,7 @@ export class Configuration {
*/
public async load(): Promise<this> {
const userConfig = await loadAndLog(USER_DEFAULTS);
const localConfig = await loadAndLog(PROJECT_LOCAL_CONFIG);
this._projectConfig = await loadAndLog(PROJECT_CONFIG);
this._projectContext = await loadAndLog(PROJECT_CONTEXT);

Expand All @@ -119,6 +121,9 @@ export class Configuration {
if (userConfig.get(['build'])) {
throw new Error('The `build` key cannot be specified in the user config (~/.cdk.json), specify it in the project config (cdk.json) instead');
}
if (localConfig.get(['build'])) {
throw new Error('The `build` key cannot be specified in the local config (cdk.local.json), specify it in the project config (cdk.json) instead');
}

const contextSources = [
this.commandLineContext,
Expand All @@ -135,6 +140,7 @@ export class Configuration {
this.settings = this.defaultConfig
.merge(userConfig)
.merge(this.projectConfig)
.merge(localConfig)
.merge(this.commandLineArguments)
.makeReadOnly();

Expand Down

0 comments on commit e4187d5

Please sign in to comment.