<commit_before>'use strict';

const gulp = tars.packages.gulp;
const replace = tars.packages.replace;
const plumber = tars.packages.plumber;
const rename = tars.packages.rename;
const through2 = tars.packages.through2;
const fs = require('fs');
const notifier = tars.helpers.notifier;
const browserSync = tars.packages.browserSync;
const generateStaticPath = require(tars.root + '/tasks/html/helpers/generate-static-path');

let patterns = [];

/**
 * Traverse recursively through data-object
 * If any property is a funciton,
 * this function will be called
 * @param  {Object} obj      Current object to traverse in current step
 * @param  {Object} fullData Object with all data
 */
function traverseThroughObject(obj, fullData) {
    for (let property in obj) {
        if (obj.hasOwnProperty(property)) {
            if (typeof obj[property] === 'object') {
                traverseThroughObject(obj[property], fullData);
            }

            if (typeof obj[property] === 'function') {
                obj[property] = obj[property].call(null, fullData);
            }
        }
    }
}

/**
 * Concat all data for all modules to one file
 * @return {Object} Object with data for modules
 */
function concatModulesData() {
    let dataEntry;
    let readyModulesData;

    try {
        dataEntry = fs.readFileSync('./dev/temp/modulesData.js', 'utf8');
    } catch (er) {
        dataEntry = false;
    }

    if (dataEntry) {
        eval('readyModulesData = {' + dataEntry + '}');
        traverseThroughObject(readyModulesData, readyModulesData);
    } else {
        readyModulesData = '{}';
    }

    // Add helpers for Jade into readyModulesData in case of using Jade as templater
    if (tars.templater.name === 'jade') {
        readyModulesData = Object.assign(readyModulesData, {
            jadeHelpers: require(tars.root + '/tasks/html/helpers/jade-helpers')
        });
    }

    return readyModulesData;
}

if (!tars.flags.ie8 && !tars.flags.ie) {
    patterns.push(
        {
            match: /<!--\[if IE 8.*endif\]-->|<!--\[if lt IE 9.*endif\]-->/gm,
            replacement: ''
        }
    );
}

if (!tars.flags.ie9 && !tars.flags.ie) {
    patterns.push(
        {
            match: /<!--\[if IE 9.*endif\]-->/gm,
            replacement: ''
        }
    );
}

patterns.push(
    {
        match: '%=min=%',
        replacement: tars.flags.min || tars.flags.release ? '.min' : ''
    }, {
        match: '%=hash=%',
        replacement: tars.flags.release ? tars.options.build.hash : ''
    }
);

if (
    tars.config.svg.active && tars.config.svg.workflow === 'symbols' &&
    tars.config.svg.symbolsConfig.loadingType === 'inject'
) {
    patterns.push(
        {
            match: '%=symbols=%',
            replacement: (() => {

                /* eslint-disable no-unused-vars */

                try {
                    return fs.readFileSync('./dev/temp/svg-symbols.svg', 'utf8');
                } catch(error) {
                    return '';
                }

                /* eslint-enable no-unused-vars */
            })
        }
    );
} else {
    patterns.push(<commit_msg>HOTFIX: fix compile-html task [ci skip][skip ci]<commit_after>'use strict';

const gulp = tars.packages.gulp;
const replace = tars.packages.replace;
const plumber = tars.packages.plumber;
const rename = tars.packages.rename;
const through2 = tars.packages.through2;
const fs = require('fs');
const notifier = tars.helpers.notifier;
const browserSync = tars.packages.browserSync;
const generateStaticPath = require(tars.root + '/tasks/html/helpers/generate-static-path');

let patterns = [];

/**
 * Traverse recursively through data-object
 * If any property is a funciton,
 * this function will be called
 * @param  {Object} obj      Current object to traverse in current step
 * @param  {Object} fullData Object with all data
 */
function traverseThroughObject(obj, fullData) {
    for (let property in obj) {
        if (obj.hasOwnProperty(property)) {
            if (typeof obj[property] === 'object') {
                traverseThroughObject(obj[property], fullData);
            }

            if (typeof obj[property] === 'function') {
                obj[property] = obj[property].call(null, fullData);
            }
        }
    }
}

/**
 * Concat all data for all modules to one file
 * @return {Object} Object with data for modules
 */
function concatModulesData() {
    let dataEntry;
    let readyModulesData;

    try {
        dataEntry = fs.readFileSync('./dev/temp/modulesData.js', 'utf8');
    } catch (er) {
        dataEntry = false;
    }

    if (dataEntry) {
        eval('readyModulesData = {' + dataEntry + '}');
        traverseThroughObject(readyModulesData, readyModulesData);
    } else {
        readyModulesData = '{}';
    }

    // Add helpers for Jade into readyModulesData in case of using Jade as templater
    if (tars.templater.name === 'jade') {
        readyModulesData = Object.assign(readyModulesData, {
            jadeHelpers: require(tars.root + '/tasks/html/helpers/jade-helpers')
        });
    }

    return readyModulesData;
}

if (!tars.flags.ie8 && !tars.flags.ie) {
    patterns.push(
        {
            match: /<!--\[if IE 8.*endif\]-->|<!--\[if lt IE 9.*endif\]-->/gm,
            replacement: ''
        }
    );
}

if (!tars.flags.ie9 && !tars.flags.ie) {
    patterns.push(
        {
            match: /<!--\[if IE 9.*endif\]-->/gm,
            replacement: ''
        }
    );
}

patterns.push(
    {
        match: '%=min=%',
        replacement: tars.flags.min || tars.flags.release ? '.min' : ''
    }, {
        match: '%=hash=%',
        replacement: tars.flags.release ? tars.options.build.hash : ''
    }
);

if (
    tars.config.svg.active && tars.config.svg.workflow === 'symbols' &&
    tars.config.svg.symbolsConfig.loadingType === 'inject'
) {
    patterns.push(
        {
            match: '%=symbols=%',
            replacement: (() => {

                /* eslint-disable no-unused-vars */

                try {
                    return fs.readFileSync('./dev/temp/svg-symbols' + tars.options.build.hash + '.svg', 'utf8');
                } catch(error) {
                    return '';
                }

                /* eslint-enable no-unused-vars */
            })
        }
    );
} else {
    patterns.push(
{'fraction_non_alphanumeric': 0.1479785217940619, 'fraction_numerical': 0.002842703727100442, 'mean_word_length': 2.0817518248175184, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '5509147', 'n_tokens_mistral': 1958, 'n_tokens_neox': 1956, 'n_words': 413}