mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-18 14:36:26 +01:00
Update config loader
This commit is contained in:
parent
bce64d9f21
commit
f53c8199c2
@ -6,6 +6,7 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
||||
{
|
||||
private _definitions: Map<string, unknown>;
|
||||
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<string[]>('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;
|
||||
|
Loading…
Reference in New Issue
Block a user