Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props: AppProps = {}) {
super(undefined as any, '');
Object.defineProperty(this, APP_SYMBOL, { value: true });
this.loadContext(props.context);
if (props.stackTraces === false) {
this.node.setContext(cxapi.DISABLE_METADATA_STACK_TRACE, true);
}
if (props.runtimeInfo === false) {
this.node.setContext(cxapi.DISABLE_VERSION_REPORTING, true);
}
// both are reverse logic
this.runtimeInfo = this.node.tryGetContext(cxapi.DISABLE_VERSION_REPORTING) ? false : true;
this.outdir = props.outdir || process.env[cxapi.OUTDIR_ENV];
const autoSynth = props.autoSynth !== undefined ? props.autoSynth : cxapi.OUTDIR_ENV in process.env;
if (autoSynth) {
// synth() guarantuees it will only execute once, so a default of 'true'
// doesn't bite manual calling of the function.
process.once('beforeExit', () => this.synth());
}
public addMetadata(type: string, data: any, from?: any): void {
if (data == null) {
return;
}
const trace = this.tryGetContext(cxapi.DISABLE_METADATA_STACK_TRACE) ? undefined : captureStackTrace(from || this.addMetadata);
this._metadata.push({ type, data, trace });
}