child_process#ExecSyncOptions TypeScript Examples

The following examples show how to use child_process#ExecSyncOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: setup.ts    From earl with MIT License 6 votes vote down vote up
function exec(command: string, { errorMsg, ...options }: ExecSyncOptions & { errorMsg?: string }) {
  try {
    execSync(command, {
      ...options,
      stdio: 'pipe',
      encoding: 'utf-8',
    })
  } catch (err) {
    console.error(...['?', errorMsg && red(errorMsg), (err as Error).message].filter(Boolean).join(' '))
    process.exit(1)
  }
}
Example #2
Source File: nx-dotnet.spec.ts    From nx-dotnet with MIT License 6 votes vote down vote up
execSyncOptions: () => ExecSyncOptions = () => ({
  cwd: join(smokeDirectory, 'test'),
  env: {
    ...process.env,
    GIT_COMMITTER_NAME: 'Smoke Test CI',
    GIT_COMMITTER_EMAIL: '[email protected]',
    GIT_AUTHOR_NAME: 'Smoke Test CI',
    GIT_AUTHOR_EMAIL: '[email protected]',
  },
  stdio: 'inherit',
})
Example #3
Source File: _utils.ts    From pebula-node with MIT License 6 votes vote down vote up
export function execute(cmd: string, options?: ExecSyncOptions) {
  execSync(cmd, { ...(options || {}), stdio: 'inherit' } );
}
Example #4
Source File: WebpackUtils.ts    From design-systems-cli with MIT License 5 votes vote down vote up
/** Install package to tmp dir and run webpack on it to calculate size. */
async function getSizes(options: GetSizesOptions & CommonOptions) {
  const dir = mockPackage();
  const execOptions: ExecSyncOptions = {
    cwd: dir,
    stdio: getLogLevel() === 'trace' ? 'inherit' : 'ignore'
  };
  try {
    const browsersList = path.join(getMonorepoRoot(), '.browserslistrc');
    if (fs.existsSync(browsersList)) {
      fs.copyFileSync(browsersList, path.join(dir, '.browserslistrc'));
    }

    const npmrc = path.join(getMonorepoRoot(), '.npmrc');
    if (options.registry && fs.existsSync(npmrc)) {
      fs.copyFileSync(npmrc, path.join(dir, '.npmrc'));
    }

    logger.debug(`Installing: ${options.name}`);
    if (options.registry) {
      execSync(
        `yarn add ${options.name} --registry ${options.registry}`,
        execOptions
      );
    } else {
      execSync(`yarn add ${options.name}`, execOptions);
    }
  } catch (error) {
    logger.debug(error);
    logger.warn(`Could not find package ${options.name}...`);
    return [];
  }

  const result = await runWebpack(
    await config({
      dir,
      ...options
    })
  );
  logger.debug(`Completed building: ${dir}`);
  if (options.persist) {
    const folder = `bundle-${options.scope}-${options.importName}`;
    const out = path.join(process.cwd(), folder);
    logger.info(`Persisting output to: ${folder}`);
    await fs.remove(out);
    await fs.copy(dir, out);
    await fs.writeFile(`${out}/stats.json`, JSON.stringify(result.toJson()));
    await fs.writeFile(
      `${out}/.gitignore`,
      'node_modules\npackage.json\npackage-lock.json\nstats.json'
    );
    execSync('git init', { cwd: out });
    execSync('prettier --single-quote "**/*.{css,js}" --write', { cwd: out });
    execSync('git add .', { cwd: out });
    execSync('git commit -m "init"', { cwd: out });
  }

  fs.removeSync(dir);
  if (result.hasErrors()) {
    throw new Error(result.toString('errors-only'));
  }

  const { assets } = result.toJson();
  if (!assets) {
    return [];
  }

  return assets;
}
Example #5
Source File: index.ts    From design-systems-cli with MIT License 5 votes vote down vote up
execOptions: ExecSyncOptions = {
  stdio: logLevel === 'debug' || logLevel === 'trace' ? 'inherit' : 'ignore',
}