How to use the @stryker-mutator/util.childProcessAsPromised.exec function in @stryker-mutator/util

To help you get started, we’ve selected a few @stryker-mutator/util 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 stryker-mutator / stryker / packages / core / src / input / InputFileResolver.ts View on Github external
private async resolveFilesUsingGit(): Promise {
    try {
      const { stdout } = await childProcessAsPromised.exec(`git ls-files --others --exclude-standard --cached --exclude /${this.tempDirName}/*`, {
        maxBuffer: 10 * 1000 * 1024
      });
      const fileNames = stdout
        .toString()
        .split('\n')
        .map(line => line.trim())
        .filter(line => line) // remove empty lines
        .map(relativeFileName => path.resolve(relativeFileName));
      return fileNames;
    } catch (error) {
      throw new StrykerError(
        normalizeWhitespaces(
          `Cannot determine input files. Either specify a \`files\`
        array in your stryker configuration, or make sure "${process.cwd()}"
        is located inside a git repository`
        ),
github stryker-mutator / stryker / packages / stryker / src / input / InputFileResolver.ts View on Github external
private async resolveFilesUsingGit(): Promise {
    try {
      const { stdout } = await childProcessAsPromised.exec(
        'git ls-files --others --exclude-standard --cached --exclude .stryker-tmp',
        { maxBuffer: 10 * 1000 * 1024 }
      );
      const fileNames = stdout.toString()
        .split('\n')
        .map(line => line.trim())
        .filter(line => line) // remove empty lines
        .map(relativeFileName => path.resolve(relativeFileName));
      return fileNames;
    } catch (error) {
      throw new StrykerError(normalizeWhiteSpaces(
        `Cannot determine input files. Either specify a \`files\`
        array in your stryker configuration, or make sure "${process.cwd()}"
        is located inside a git repository`),
        error
      );
github stryker-mutator / stryker / packages / core / src / initializer / StrykerConfigWriter.ts View on Github external
private async writeStrykerConfigRaw(rawConfig: string, rawHeader = '') {
    this.out('Writing & formatting stryker.conf.js...');
    const formattedConf = `${rawHeader}
      module.exports = function(config){
        config.set(
          ${rawConfig}
        );
      }`;
    await fsAsPromised.writeFile(STRYKER_CONFIG_FILE, formattedConf);
    try {
      await childProcessAsPromised.exec(`npx prettier --write ${STRYKER_CONFIG_FILE}`);
    } catch (error) {
      this.log.debug('Prettier exited with error', error);
      this.out('Unable to format stryker.conf.js file for you. This is not a big problem, but it might look a bit messy 🙈.');
    }
  }