<commit_before>/*
 * Copy lib images & rebase urls
 */
module.exports = function (grunt) {
    grunt.registerTask('libcssimg', 'Copy lib images & rebase urls', function () {
        var css = grunt.file.read('css/lib.css'),
            out = css,
            urls = /url\((['"]?)(.+?)\1\)/g,
            repl = {
                'jquery-ui':    /^\.\.\/lib\/jquery-ui-.+?\/images\/ui-/,
                'select2':      /^\.\.\/lib\/select2\//,
                'jquery-upl':   /^\.\.\/lib\/jquery-fileupload\/img\//
            },
            done = {},
            url,
            dest,
            to;

        grunt.file.mkdir('img/lib');

        while ((url = urls.exec(css)) !== null) {
            for (to in repl) {
                dest = url[2].replace(repl[to], 'img/lib/' + to + '-');
                if (dest !== url[2]) {
                    if (!done[dest]) {
                        grunt.file.copy(url[2].replace(/^\.\.\/lib\//, 'lib/'), dest);
                        out = out.replace(
                            new RegExp(url[0].replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), 'g'),
                            'url(' + url[1] + '../' + dest + url[1] + ')'
                        );
                        done[dest] = 1;
                    }
                    break;
                } else {
                    dest = false;
                }
            }
            if (!dest && !url[2].match(/^data:/)) {
                grunt.fail.warn('URL not handled: ' + url[2]);
            }
        }
        grunt.file.write('css/lib.css', out);
    });
};<commit_msg>Make usage of grunt templates in libcssimg task<commit_after>/*
 * Copy lib images & rebase urls
 */
module.exports = function (grunt, option) {
    grunt.registerTask('libcssimg', 'Copy lib images & rebase urls', function () {
        var css = grunt.file.read(option.path.dest.css + '/lib.css'),
            out = css,
            urls = /url\((['"]?)(.+?)\1\)/g,
            repl = {
                'jquery-ui':    /^\.\.\/lib\/jquery-ui-.+?\/images\/ui-/,
                'select2':      /^\.\.\/lib\/select2\//,
                'jquery-upl':   /^\.\.\/lib\/jquery-fileupload\/img\//
            },
            done = {},
            url,
            dest,
            to;

        grunt.file.mkdir(option.path.dest.img + '/lib');

        while ((url = urls.exec(css)) !== null) {
            for (to in repl) {
                dest = url[2].replace(repl[to], option.path.dest.img + '/lib/' + to + '-');
                if (dest !== url[2]) {
                    if (!done[dest]) {
                        grunt.file.copy(url[2].replace(/^\.\.\/lib\//, 'lib/'), dest);
                        out = out.replace(
                            new RegExp(url[0].replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), 'g'),
                            'url(' + url[1] + '../' + dest + url[1] + ')'
                        );
                        done[dest] = 1;
                    }
                    break;
                } else {
                    dest = false;
                }
            }
            if (!dest && !url[2].match(/^data:/)) {
                grunt.fail.warn('URL not handled: ' + url[2]);
            }
        }
        grunt.file.write(option.path.dest.css + '/lib.css', out);
    });
};
{'fraction_non_alphanumeric': 0.20820668693009117, 'fraction_numerical': 0.00729483282674772, 'mean_word_length': 1.0177805027590436, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5971171', 'n_tokens_mistral': 1042, 'n_tokens_neox': 999, 'n_words': 170}