From f53c8199c2d3e79800838950b74baa1557fc3e8b Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 17 Dec 2021 20:03:27 -0500 Subject: [PATCH] Update config loader --- .../configuration/ConfigurationManager.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/configuration/ConfigurationManager.ts b/src/core/configuration/ConfigurationManager.ts index b829ffe9..5b6aef3f 100644 --- a/src/core/configuration/ConfigurationManager.ts +++ b/src/core/configuration/ConfigurationManager.ts @@ -6,6 +6,7 @@ export class ConfigurationManager extends NitroManager implements IConfiguration { private _definitions: Map; private _pendingUrls: string[]; + private _missingKeys: string[]; constructor() { @@ -13,16 +14,16 @@ export class ConfigurationManager extends NitroManager implements IConfiguration this._definitions = new Map(); this._pendingUrls = []; + this._missingKeys = []; this.onConfigurationLoaded = this.onConfigurationLoaded.bind(this); } protected onInit(): void { - //@ts-ignore - const defaultConfig = this.getDefaultConfig(); + this.parseConfiguration(this.getDefaultConfig()); - this._pendingUrls = defaultConfig['config.urls'] as string[]; + this._pendingUrls = this.getValue('config.urls').slice(); this.loadNextConfiguration(); } @@ -33,8 +34,6 @@ export class ConfigurationManager extends NitroManager implements IConfiguration { this.dispatchConfigurationEvent(ConfigurationEvent.LOADED); - this.parseConfiguration(this.getDefaultConfig()); - return; } @@ -94,14 +93,13 @@ export class ConfigurationManager extends NitroManager implements IConfiguration for(const key in data) { + if(this._definitions.has(key)) continue; + let value = data[key]; - if(typeof value === 'string') - { - value = this.interpolate((value as string), regex); - } + if(typeof value === 'string') value = this.interpolate((value as string), regex); - this._definitions.set(key, value); + this.setValue(key, value); } return true; @@ -145,6 +143,9 @@ export class ConfigurationManager extends NitroManager implements IConfiguration if(existing === undefined) { + if(this._missingKeys.indexOf(key) >= 0) return value; + + this._missingKeys.push(key); this.logger.warn(`Missing configuration key: ${ key }`); existing = value;