<commit_before>/*
 * grunt-uniqueify
 * https://github.com/ajmichels/grunt-uniqueify
 *
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT license.
 *
 * Thanks to <NAME> (https://github.com/cbas/grunt-rev)
 *
 */

var crypto = require('crypto');
var path = require('path');
var fs = require('fs');

module.exports = function(grunt) {
    'use strict';

    var fileHash = function(filepath, algorithm) {
        var hash = crypto.createHash(algorithm);
        grunt.log.verbose.write('Hashing ' + filepath + '...');
        hash.update(grunt.file.read(filepath));
        return hash.digest('hex');
    };

    var textReplace = function(src, find, replace, filePath) {
        var newText = src.replace(find, replace);
        if (newText != src) {
            grunt.log.write(filePath + ' : ' + find + ' ').ok(replace);
        }
        return newText;
    };

    grunt.registerMultiTask('uniqueify', 'Updated file names and replace instances of the old name with the new name.', function(){
        var options = this.options({
            algorithm: 'md5',
            length: 8
        });

        // Rename the file
        grunt.event.on('uniqueify.rename', function(oldFile, newFile){
            fs.renameSync(oldFile, newFile);
            grunt.log.write(oldFile + ' ').ok(newFile);
        });

        // Replace instances of filename in code
        grunt.event.on('uniqueify.rename', function(oldFile, newFile){
            if (!options.replaceSrc) {
                grunt.log.warn('No src replacement paths (options.replaceSrc) defined in options.');
            }
            else {
                var find = path.basename(oldFile);
                var replace = path.basename(newFile);
                var targets = grunt.file.expand(options.replaceSrc);

                targets.forEach(function(filePath){
                    grunt.file.copy(filePath, filePath, {
                        process: function(text){<commit_msg>fix: Replace all instances of a filename<commit_after>/*
 * grunt-uniqueify
 * https://github.com/ajmichels/grunt-uniqueify
 *
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT license.
 *
 * Thanks to <NAME> (https://github.com/cbas/grunt-rev)
 *
 */

var crypto = require('crypto');
var path = require('path');
var fs = require('fs');

module.exports = function(grunt) {
    'use strict';

    var fileHash = function(filepath, algorithm) {
        var hash = crypto.createHash(algorithm);
        grunt.log.verbose.write('Hashing ' + filepath + '...');
        hash.update(grunt.file.read(filepath));
        return hash.digest('hex');
    };

    var textReplace = function(src, find, replace, filePath) {
        var newText = src.replace(new RegExp(find, 'g'), replace);
        if (newText != src) {
            grunt.log.write(filePath + ' : ' + find + ' ').ok(replace);
        }
        return newText;
    };

    grunt.registerMultiTask('uniqueify', 'Updated file names and replace instances of the old name with the new name.', function(){
        var options = this.options({
            algorithm: 'md5',
            length: 8
        });

        // Rename the file
        grunt.event.on('uniqueify.rename', function(oldFile, newFile){
            fs.renameSync(oldFile, newFile);
            grunt.log.write(oldFile + ' ').ok(newFile);
        });

        // Replace instances of filename in code
        grunt.event.on('uniqueify.rename', function(oldFile, newFile){
            if (!options.replaceSrc) {
                grunt.log.warn('No src replacement paths (options.replaceSrc) defined in options.');
            }
            else {
                var find = path.basename(oldFile);
                var replace = path.basename(newFile);
                var targets = grunt.file.expand(options.replaceSrc);

                targets.forEach(function(filePath){
                    grunt.file.copy(filePath, filePath, {
                        process: function(text){
{'fraction_non_alphanumeric': 0.1346153846153846, 'fraction_numerical': 0.003036437246963563, 'mean_word_length': 2.1751004016064255, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, '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': '1956466', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1118, 'n_words': 259}