<commit_before>'use strict';


var Chalk = require('chalk');
var Util = require('util');
var Uglifyjs = require('uglify-js');

exports.init = function(grunt, options) {
    var exports = {},
        isWindows = process.platform === 'win32';


    exports.unixifyPath = function (filePath) {
        return isWindows ?  filePath.replace(/\\/g, '/') : filePath;
    };

    exports.replace = function (files, search, replace, doNotPrependPath) {
        // fix file paths with buildpath

        for(var i = 0; i < files.length; i++) {
            files[i] = exports.unixifyPath(
                !!doNotPrependPath ?  files[i] :  options.appBuildPath + files[i]
            );
        }

        var filePaths = grunt.file.expand(files),
            fileContent,
            updatedContent;

        if (!(search instanceof Array)) {
            grunt.log.writeln('# Replace:' + Chalk.cyan(search) + ' With:' + Chalk.red(replace));
        }
        filePaths.forEach(function(filepath) {
            //grunt.log.writeln(filepath);

            if (!grunt.file.exists(filepath)) {
                grunt.fail.warn(Chalk.bold.red('Source file "' + filepath + '" not found.'));
            } else {
                grunt.log.writeln('File:' + Chalk.yellow(filepath));
                fileContent = grunt.file.read(filepath, {encoding:'utf8'});
                if (search instanceof Array) {
                    updatedContent = fileContent;
                    for(var i = 0; i < search.length; i++) {
                        grunt.log.writeln(i + '# Replace:' + Chalk.cyan(search[i]) + ' With:' + Chalk.red(replace[i]));
                        if (search[i].test(String(updatedContent))) {
                            updatedContent = String(updatedContent).replace(search[i], replace[i]);
                        } else {
                            if (doNotPrependPath) { // ONLY TEMPLATES MATCH NOT FOUND IS SUPRESSED OTHERWISE WARNING
                                grunt.log.warn(Chalk.bold.red('No Match Found'));
                            } else {
                                grunt.fail.warn(Chalk.bold.red('No Match Found'));
                            }
                        }
                    }
                } else {
                    updatedContent = fileContent;
                    if (search.test(String(updatedContent))) {
                        updatedContent = String(updatedContent).replace(search, replace);
                    } else {
                        if (doNotPrependPath) { // ONLY TEMPLATES MATCH NOT FOUND IS SUPRESSED OTHERWISE WARNING
                            grunt.log.warn(Chalk.bold.red('No Match Found'));
                        } else {
                            grunt.fail.warn(Chalk.bold.red('No Match Found'));
                        }
                    }
                }
                grunt.file.write(filepath, updatedContent);
            }
        });
    };

    exports.uglify = function(src, dest, uglifyOptions) {
        var result, err ;
        src = exports.unixifyPath(src);
        dest = exports.unixifyPath(dest);
        try {
            result = Uglifyjs.minify(src, uglifyOptions);
        } catch(e) {
            err = new Error('Uglification failed.');
            if (e.message) {
                err.message += '\n' + e.message + '. \n';
                if (e.line) {
                    err.message += 'Line ' + e.line + ' in ' + src + '\n';
                }

            }
            err.origError = e;
            grunt.log.warn(Chalk.bold.red('Uglifying source ' + src + ' failed.'));
            grunt.fail.error(err);
        }

        var output = Util.format(uglifyOptions.banner, grunt.template.today('yyyy-mm-dd')) + result.code;<commit_msg>regex,string replace function does not raise warning<commit_after>'use strict';


var Chalk = require('chalk');
var Util = require('util');
var Uglifyjs = require('uglify-js');

exports.init = function(grunt, options) {
    var exports = {},
        isWindows = process.platform === 'win32';


    exports.unixifyPath = function (filePath) {
        return isWindows ?  filePath.replace(/\\/g, '/') : filePath;
    };

    exports.replace = function (files, search, replace, doNotPrependPath) {
        // fix file paths with buildpath

        for(var i = 0; i < files.length; i++) {
            files[i] = exports.unixifyPath(
                !!doNotPrependPath ?  files[i] :  options.appBuildPath + files[i]
            );
        }

        var filePaths = grunt.file.expand(files),
            fileContent,
            updatedContent;

        if (!(search instanceof Array)) {
            grunt.log.writeln('# Replace:' + Chalk.cyan(search) + ' With:' + Chalk.red(replace));
        }
        filePaths.forEach(function(filepath) {
            //grunt.log.writeln(filepath);

            if (!grunt.file.exists(filepath)) {
                grunt.fail.warn(Chalk.bold.red('Source file "' + filepath + '" not found.'));
            } else {
                grunt.log.writeln('File:' + Chalk.yellow(filepath));
                fileContent = grunt.file.read(filepath, {encoding:'utf8'});
                if (search instanceof Array) {
                    updatedContent = fileContent;
                    for(var i = 0; i < search.length; i++) {
                        grunt.log.writeln(i + '# Replace:' + Chalk.cyan(search[i]) + ' With:' + Chalk.red(replace[i]));
                        if (search[i].test(String(updatedContent))) {
                            updatedContent = String(updatedContent).replace(search[i], replace[i]);
                        } else {
                            grunt.log.warn(Chalk.bold.red('No Match Found'));
                        }
                    }
                } else {
                    updatedContent = fileContent;
                    if (search.test(String(updatedContent))) {
                        updatedContent = String(updatedContent).replace(search, replace);
                    } else {
                        grunt.log.warn(Chalk.bold.red('No Match Found'));
                    }
                }
                grunt.file.write(filepath, updatedContent);
            }
        });
    };

    exports.uglify = function(src, dest, uglifyOptions) {
        var result, err ;
        src = exports.unixifyPath(src);
        dest = exports.unixifyPath(dest);
        try {
            result = Uglifyjs.minify(src, uglifyOptions);
        } catch(e) {
            err = new Error('Uglification failed.');
            if (e.message) {
                err.message += '\n' + e.message + '. \n';
                if (e.line) {
                    err.message += 'Line ' + e.line + ' in ' + src + '\n';
                }

            }
            err.origError = e;
            grunt.log.warn(Chalk.bold.red('Uglifying source ' + src + ' failed.'));
            grunt.fail.error(err);
        }

        var output = Util.format(uglifyOptions.banner, grunt.template.today('yyyy-mm-dd')) + result.code;
{'fraction_non_alphanumeric': 0.13267778252814594, 'fraction_numerical': 0.0014251104460595695, 'mean_word_length': 1.5001781261132883, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1836094', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1905, 'n_words': 363}