How to use the @stryker-mutator/util.normalizeWhitespaces 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`
        ),
        error
      );
    }
  }
github stryker-mutator / stryker / packages / core / src / Sandbox.ts View on Github external
await symlinkJunction(nodeModules, path.join(this.workingDirectory, 'node_modules')).catch((error: NodeJS.ErrnoException) => {
          if (error.code === 'EEXIST') {
            this.log.warn(
              normalizeWhitespaces(`Could not symlink "${nodeModules}" in sandbox directory,
              it is already created in the sandbox. Please remove the node_modules from your sandbox files.
              Alternatively, set \`symlinkNodeModules\` to \`false\` to disable this warning.`)
            );
          } else {
            this.log.warn(`Unexpected error while trying to symlink "${nodeModules}" in sandbox directory.`, error);
          }
        });
      } else {
github stryker-mutator / stryker / packages / core / src / input / InputFileCollection.ts View on Github external
public logFiles(log: Logger) {
    if (!this.files.length) {
      log.warn(
        `No files selected. Please make sure you either${os.EOL}` +
          ` (1) Run Stryker inside a Git repository; or${os.EOL}` +
          ' (2) Specify the `files` property in your Stryker configuration (`--files via command line`).'
      );
    } else {
      if (this.filesToMutate.length) {
        log.info(`Found ${this.filesToMutate.length} of ${this.files.length} file(s) to be mutated.`);
      } else {
        log.warn(
          normalizeWhitespaces(`No files marked to be mutated, Stryker will perform a dry-run without actually mutating anything.
        You can configure the \`mutate\` property in your stryker.conf.js file (or use \`--mutate\` via command line).`)
        );
      }
      if (log.isDebugEnabled()) {
        log.debug(
          `All input files: ${JSON.stringify(
            this.files.map(file => file.name),
            null,
            2
          )}`
        );
        log.debug(
          `Files to mutate: ${JSON.stringify(
            this.filesToMutate.map(file => file.name),
            null,
            2
github stryker-mutator / stryker / packages / core / src / reporters / MutationTestReportCalculator.ts View on Github external
results.forEach(mutantResult => {
      const fileResult = resultDictionary[mutantResult.sourceFilePath];
      if (fileResult) {
        fileResult.mutants.push(this.toMutantResult(mutantResult));
      } else {
        const sourceFile = this.inputFiles.files.find(file => file.name === mutantResult.sourceFilePath);
        if (sourceFile) {
          resultDictionary[mutantResult.sourceFilePath] = {
            language: this.determineLanguage(sourceFile.name),
            mutants: [this.toMutantResult(mutantResult)],
            source: sourceFile.textContent
          };
        } else {
          this.log.warn(
            normalizeWhitespaces(`File "${mutantResult.sourceFilePath}" not found
          in input files, but did receive mutant result for it. This shouldn't happen`)
          );
        }
      }
    });
    return resultDictionary;