Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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());
}
if (props.treeMetadata === undefined || props.treeMetadata) {
new TreeMetadata(this);
}
}
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());
}
if (props.treeMetadata === undefined || props.treeMetadata) {
new TreeMetadata(this);
}
}
// by pass "synth" if app points to a cloud assembly
if (await fs.pathExists(app) && (await fs.stat(app)).isDirectory()) {
debug('--app points to a cloud assembly, so we by pass synth');
return new cxapi.CloudAssembly(app);
}
const commandLine = await guessExecutable(appToArray(app));
const outdir = config.settings.get([ 'output' ]);
if (!outdir) {
throw new Error('unexpected: --output is required');
}
await fs.mkdirp(outdir);
debug('outdir:', outdir);
env[cxapi.OUTDIR_ENV] = outdir;
// Send version information
env[cxapi.CLI_ASM_VERSION_ENV] = cxapi.CLOUD_ASSEMBLY_VERSION;
env[cxapi.CLI_VERSION_ENV] = versionNumber();
debug('env:', env);
await exec();
return new cxapi.CloudAssembly(outdir);
async function exec() {
return new Promise((ok, fail) => {
// We use a slightly lower-level interface to:
//
// - Pass arguments in an array instead of a string, to get around a