Update config loader

This commit is contained in:
Bill 2021-12-17 20:03:27 -05:00
parent bce64d9f21
commit f53c8199c2

View File

@ -6,6 +6,7 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
{ {
private _definitions: Map<string, unknown>; private _definitions: Map<string, unknown>;
private _pendingUrls: string[]; private _pendingUrls: string[];
private _missingKeys: string[];
constructor() constructor()
{ {
@ -13,16 +14,16 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
this._definitions = new Map(); this._definitions = new Map();
this._pendingUrls = []; this._pendingUrls = [];
this._missingKeys = [];
this.onConfigurationLoaded = this.onConfigurationLoaded.bind(this); this.onConfigurationLoaded = this.onConfigurationLoaded.bind(this);
} }
protected onInit(): void protected onInit(): void
{ {
//@ts-ignore this.parseConfiguration(this.getDefaultConfig());
const defaultConfig = this.getDefaultConfig();
this._pendingUrls = defaultConfig['config.urls'] as string[]; this._pendingUrls = this.getValue<string[]>('config.urls').slice();
this.loadNextConfiguration(); this.loadNextConfiguration();
} }
@ -33,8 +34,6 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
{ {
this.dispatchConfigurationEvent(ConfigurationEvent.LOADED); this.dispatchConfigurationEvent(ConfigurationEvent.LOADED);
this.parseConfiguration(this.getDefaultConfig());
return; return;
} }
@ -94,14 +93,13 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
for(const key in data) for(const key in data)
{ {
if(this._definitions.has(key)) continue;
let value = data[key]; let value = data[key];
if(typeof value === 'string') if(typeof value === 'string') value = this.interpolate((value as string), regex);
{
value = this.interpolate((value as string), regex);
}
this._definitions.set(key, value); this.setValue(key, value);
} }
return true; return true;
@ -145,6 +143,9 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
if(existing === undefined) if(existing === undefined)
{ {
if(this._missingKeys.indexOf(key) >= 0) return value;
this._missingKeys.push(key);
this.logger.warn(`Missing configuration key: ${ key }`); this.logger.warn(`Missing configuration key: ${ key }`);
existing = value; existing = value;