How to use @stryker-mutator/util - 10 common examples

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 / 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 / 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`
        ),
        error
      );
    }
  }
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 / 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`
        ),
        error
      );
    }
  }
github stryker-mutator / stryker / packages / core / src / di / PluginLoader.ts View on Github external
this.pluginDescriptors.forEach(pluginExpression => {
      if (typeof pluginExpression === 'string') {
        if (pluginExpression.includes('*')) {
          // Plugin directory is the node_modules folder of the module that installed stryker
          // So if current __dirname is './@stryker-mutator/core/src/di' so 4 directories above
          const pluginDirectory = path.dirname(path.resolve(__dirname, '..', '..', '..', '..', pluginExpression));
          const regexp = new RegExp('^' + path.basename(pluginExpression).replace('*', '.*'));

          this.log.debug('Loading %s from %s', pluginExpression, pluginDirectory);
          const plugins = fsAsPromised
            .readdirSync(pluginDirectory)
            .filter(pluginName => !IGNORED_PACKAGES.includes(pluginName) && regexp.test(pluginName))
            .map(pluginName => path.resolve(pluginDirectory, pluginName));
          if (plugins.length === 0) {
            this.log.debug('Expression %s not resulted in plugins to load', pluginExpression);
          }
          plugins
            .map(plugin => {
              this.log.debug('Loading plugin "%s" (matched with expression %s)', plugin, pluginExpression);
              return plugin;
            })
            .forEach(p => modules.push(p));
        } else {
          modules.push(pluginExpression);
        }
      } else {
github stryker-mutator / stryker / packages / stryker / src / di / PluginLoader.ts View on Github external
this.pluginDescriptors.forEach(pluginExpression => {
      if (_.isString(pluginExpression)) {
        if (pluginExpression.indexOf('*') !== -1) {

          // Plugin directory is the node_modules folder of the module that installed stryker
          // So if current __dirname is './stryker/src/di' so 3 directories above
          const pluginDirectory = path.resolve(__dirname, '..', '..', '..');
          const regexp = new RegExp('^' + pluginExpression.replace('*', '.*'));

          this.log.debug('Loading %s from %s', pluginExpression, pluginDirectory);
          const plugins = fsAsPromised.readdirSync(pluginDirectory)
            .filter(pluginName => IGNORED_PACKAGES.indexOf(pluginName) === -1 && regexp.test(pluginName))
            .map(pluginName => pluginDirectory + '/' + pluginName);
          if (plugins.length === 0) {
            this.log.debug('Expression %s not resulted in plugins to load', pluginExpression);
          }
          plugins
            .map(plugin => path.basename(plugin))
            .map(plugin => {
              this.log.debug('Loading plugins %s (matched with expression %s)', plugin, pluginExpression);
              return plugin;
            })
            .forEach(p => modules.push(p));
        } else {
          modules.push(pluginExpression);
        }
      } else {
github stryker-mutator / stryker / packages / stryker / src / input / InputFileResolver.ts View on Github external
private readFile(fileName: string): Promise {
    return fsAsPromised
      .readFile(fileName)
      .then((content: Buffer) => new File(fileName, content))
      .then((file: File) => {
        this.reportSourceFilesRead(file);
        return file;
      })
      .catch(error => {
        if (
          (isErrnoException(error) && error.code === 'ENOENT') ||
          error.code === 'EISDIR'
        ) {
          return null; // file is deleted or a directory. This can be a valid result of the git command
        } else {
          // Rethrow
          throw error;
        }
github stryker-mutator / stryker / packages / core / src / input / InputFileResolver.ts View on Github external
private readFile(fileName: string): Promise {
    return fsAsPromised
      .readFile(fileName)
      .then((content: Buffer) => new File(fileName, content))
      .then((file: File) => {
        this.reportSourceFilesRead(file);
        return file;
      })
      .catch(error => {
        if ((isErrnoException(error) && error.code === 'ENOENT') || error.code === 'EISDIR') {
          return null; // file is deleted or a directory. This can be a valid result of the git command
        } else {
          // Rethrow
          throw error;
        }
      });
  }
}
github stryker-mutator / stryker / packages / core / src / input / InputFileResolver.ts View on Github external
.catch(error => {
        if ((isErrnoException(error) && error.code === 'ENOENT') || error.code === 'EISDIR') {
          return null; // file is deleted or a directory. This can be a valid result of the git command
        } else {
          // Rethrow
          throw error;
        }
      });
  }