<commit_before>/**
 * grunt-trimtrailingspaces
 * https://github.com/paazmaya/grunt-trimtrailingspaces
 *
 * Copyright (c) <NAME> <<EMAIL>>
 * Licensed under the MIT license.
 */
'use strict';

module.exports = function trimtrailingspaces(grunt) {

  grunt.registerMultiTask('trimtrailingspaces', 'Removing the trailing spaces', function register() {
    var taskSucceeded = true;

    // Default options extended with user defined
    var options = this.options({
      encoding: 'utf8',
      failIfTrimmed: false
    });
    var fsOptions = { // Filesystem access options
      encoding: options.encoding
    };
    var changedFileCount = 0;

    this.files.forEach(function filesEach(file) {

      // Iterate src as that is where the actual files are
      file.src.forEach(function srcEach(src) {
        grunt.verbose.writeln('Processing file: ' + src);

        var content = grunt.file.read(src, fsOptions);
        var destination = src;
        var trimmed = content.replace(/[ \f\t\v]*$/gm, '');
        if (content !== trimmed) {
          grunt.verbose.writeln('Needed trimming, file: ' + src);
          ++changedFileCount;

          // dest might be undefined, thus use same directory as src
          if (typeof file.dest !== 'undefined') {
            destination = file.dest + '/' + src.split('/').pop();
          }

          grunt.file.write(destination, trimmed, fsOptions);
        }

      });
    });

    if (changedFileCount > 0 && options.failIfTrimmed) {
      grunt.fail.warn(changedFileCount + ' files had whitespace trimmed, and the failIfTrimmed option is set to true.', 6);
    }

    return taskSucceeded;
  });

};<commit_msg>Make sure that destination exists as a directory. Fixes #14<commit_after>/**
 * grunt-trimtrailingspaces
 * https://github.com/paazmaya/grunt-trimtrailingspaces
 *
 * Copyright (c) <NAME> <<EMAIL>>
 * Licensed under the MIT license.
 */
'use strict';

module.exports = function trimtrailingspaces(grunt) {

  grunt.registerMultiTask('trimtrailingspaces', 'Removing the trailing spaces', function register() {
    var taskSucceeded = true;

    // Default options extended with user defined
    var options = this.options({
      encoding: 'utf8',
      failIfTrimmed: false
    });
    var fsOptions = { // Filesystem access options
      encoding: options.encoding
    };
    var changedFileCount = 0;

    this.files.forEach(function filesEach(file) {

      // Iterate src as that is where the actual files are
      file.src.forEach(function srcEach(src) {
        grunt.verbose.writeln('Processing file: ' + src);

        var content = grunt.file.read(src, fsOptions);
        var destination = src;
        var trimmed = content.replace(/[ \f\t\v]*$/gm, '');
        if (content !== trimmed) {
          grunt.verbose.writeln('Needed trimming, file: ' + src);
          ++changedFileCount;

          // dest might be undefined, thus use same directory as src
          if (typeof file.dest === 'string') {
            if (!grunt.file.exists(file.dest)) {
              grunt.file.mkdir(file.dest);
            }
            destination = file.dest + '/' + src.split('/').pop();
          }

          grunt.file.write(destination, trimmed, fsOptions);
        }

      });
    });

    if (changedFileCount > 0 && options.failIfTrimmed) {
      grunt.fail.warn(changedFileCount + ' files had whitespace trimmed, and the failIfTrimmed option is set to true.', 6);
    }

    return taskSucceeded;
  });

};
{'fraction_non_alphanumeric': 0.1271210813920046, 'fraction_numerical': 0.0028760425654299686, 'mean_word_length': 2.5708418891170433, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4525148', 'n_tokens_mistral': 1049, 'n_tokens_neox': 998, 'n_words': 264}