Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
root = AwesomeUtils.Object.extend(root,source.content);
});
// run the resulting object through our resolver.
if (this.resolver) this.resolver.resolve(root);
// prevent our nested children from being mutated.
// We handle this for the nested child itself in the AwesomeConfig proxy.
Object.keys(root).forEach((key)=>{
AwesomeUtils.Object.deepFreeze(root[key]);
});
// make our configuration.
this[$CONFIG] = root;
Log.debug("Instance "+this.id+" initialized.");
}
if (!content) throw new Error("Missing configuration content.");
if (defaultConditions===null || defaultConditions===undefined) throw new Error("Missing defaultConditions.");
if (typeof defaultConditions!=="string") throw new Error("Invalid defaultConditions.");
if (encoding===null || encoding===undefined) throw new Error("Missing encoding.");
if (typeof encoding!=="string") throw new Error("Invalid encoding.");
let origin = null;
let sources = [];
let valid = false;
if (AwesomeUtils.Object.isPlainObject(content)) {
valid = true;
origin = AwesomeUtils.VM.executionSourceAndLine(4);
sources = sources.concat([new ConfigSource(origin,content,defaultConditions)]);
Log.debug("Instance "+(this.id?this.id:"[default]")+" added configuration from origin "+origin+".");
}
else if (typeof content==="string") {
let resolved = resolve(content);
let filename,stat;
if (resolved) ({stat,filename} = resolved);
if (!stat) {
origin = AwesomeUtils.VM.executionSourceAndLine(4);
sources = sources.concat(this.parser.parse(origin,content,defaultConditions));
if (content) valid = true;
Log.debug("Instance "+(this.id?this.id:"[default]")+" added configuration from origin "+origin+".");
}
else if (stat && stat.isDirectory()) {
Log.debug("Instance "+(this.id?this.id:"[default]")+" looking for config in directory "+filename+".");
let dir = filename;
constructor(id) {
this[$ID] = id;
this[$SOURCES] = [];
this[$CONFIG] = null;
this[$PARSER] = new ConfigParser();
this[$RESOLVER] = new ConfigResolver();
Log.debug("Instance "+id+" initialized.");
}
stop() {
if (!this.started) return;
this[$CONFIG] = null;
Log.debug("Instance "+this.id+" stopped.");
}