How to use the @aws-cdk/cx-api.CloudAssembly function in @aws-cdk/cx-api

To help you get started, we’ve selected a few @aws-cdk/cx-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cdk / packages / aws-cdk / lib / api / cxapp / exec.ts View on Github external
if (!stagingEnabled) {
    context[cxapi.DISABLE_ASSET_STAGING_CONTEXT] = true;
  }

  debug('context:', context);
  env[cxapi.CONTEXT_ENV] = JSON.stringify(context);

  const app = config.settings.get(['app']);
  if (!app) {
    throw new Error(`--app is required either in command-line, in ${PROJECT_CONFIG} or in ${USER_DEFAULTS}`);
  }

  // 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();
github aws / aws-cdk / packages / aws-cdk / lib / api / cxapp / exec.ts View on Github external
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
      //   number of quoting issues introduced by the intermediate shell layer
      //   (which would be different between Linux and Windows).
      //
      // - Inherit stderr from controlling terminal. We don't use the captured value
      //   anway, and if the subprocess is printing to it for debugging purposes the
      //   user gets to see it sooner. Plus, capturing doesn't interact nicely with some
      //   processes like Maven.
      const proc = childProcess.spawn(commandLine[0], commandLine.slice(1), {
        stdio: ['ignore', 'inherit', 'inherit'],
        detached: false,