<commit_before>var path = require('path'),
    _ = require('lodash'),

    levels = require('enb-bem-techs/techs/levels'),
    levelsToBemdecl = require('enb-bem-techs/techs/levels-to-bemdecl'),
    files = require('enb-bem-techs/techs/files'),

    provide = require('enb/techs/file-provider'),
    depsByTechToBemdecl = require('enb-bem-techs/techs/deps-by-tech-to-bemdecl'),
    deps = require('enb-bem-techs/techs/deps'),
    depsOld = require('enb-bem-techs/techs/deps-old'),
    mergeDeps = require('enb-bem-techs/techs/merge-deps'),

    keysets = require('enb-bem-i18n/techs/keysets'),
    i18n = require('enb-bem-i18n/techs/i18n'),
    mockI18N = require('./techs/mock-lang-js'),
    mergeFile = require('enb/techs/file-merge'),

    references = require('./techs/references'),
    istanbul = require('./techs/istanbul'),
    spec = require('./techs/tmpl-spec'),
    instrumentedTarget = require('./util').instrumentedTarget;

exports.configure = function (config, options) {
    var pattern = path.join(options.destPath, '*'),
        coverageRe = new RegExp('/' + options.completeBundle + '$'),
        depsTech;

    if (typeof options.depsTech === 'function') {
        depsTech = options.depsTech;
    } else if (options.depsTech === 'deps') {
        depsTech = deps;
    } else {
        depsTech = depsOld;
    }

    config.nodes(pattern, function (nodeConfig) {
        var langs = options.langs,
            engines = options.engines,
            prependFiles = [].concat(options.prependFiles).filter(Boolean),
            appendFiles = [].concat(options.appendFiles).filter(Boolean),
            coverageEngines = options.coverage.engines,
            engineTargets = [],
            specTargets = [],
            nodePath = nodeConfig.getPath(),
            isCoverageBundle = coverageRe.test(nodePath),
            sourceLevels = [].concat(options.sourceLevels, options.sublevels[nodePath] || []);

        // Base techs
        nodeConfig.addTechs([
            [levels, { levels: sourceLevels }],
            [levels, { target: '?.base.levels', levels: options.levels }],
            [isCoverageBundle ? levelsToBemdecl : provide, {
                target: '?.base.bemdecl.js'
            }],
            [depsByTechToBemdecl, {
                target: '?.tech.bemdecl.js',
                filesTarget: '?.base.files',
                sourceTech: 'tmpl-spec.js'
            }],
            [mergeDeps, {
                target: '?.bemdecl.js',
                sources: ['?.base.bemdecl.js', '?.tech.bemdecl.js']
            }],
            [depsTech],
            [files, {
                levelsTarget: '?.base.levels',
                depsFile: '?.base.bemdecl.js',
                filesTarget: '?.base.files',
                dirsTarget: '?.base.dirs'
            }],
            [files]
        ]);

        // Provide prepending and appending files if any.
        prependFiles.concat(appendFiles)
            .forEach(function (filepath) {
                nodeConfig.addTech([provide, { target: filepath }]);
            });

        // Add engines' techs and set needsCoverage flag
        engines.forEach(function (engine) {
            engine.hasOwnProperty('needsCoverage') || (engine.needsCoverage = _.contains(coverageEngines, engine.name));
            nodeConfig.addTech([engine.tech, engine.options]);
        });

        // For each lang including no-lang (false) and mock-lang (true)
        (Array.isArray(langs) ? langs : [langs && 'mock']).forEach(function (lang) {
            var isMock = lang === 'mock',
                isReal = !isMock && typeof lang === 'string',
                suffix = '.' + (lang || 'merged') + '.js';

            // Keyset and lang file for real langs:
            isReal && nodeConfig.addTechs([
                [keysets, { lang: lang }],
                [i18n, { lang: lang, exports: { globals: 'force' } }]
            ]);

            // Mock for mock-lang:
            isMock && nodeConfig.addTechs([
                [mockI18N, { target: '?.lang' + suffix, mock: options.mockI18N }]
            ]);

            engines.forEach(function (engine) {
                var target = engine.target,
                    destTarget = target,
                    sources = []
                        .concat(prependFiles)
                        .concat(lang && ('?.lang' + suffix))
                        .concat(target)<commit_msg>refactor(lodash): use `includes` instead of `contains`<commit_after>var path = require('path'),
    _ = require('lodash'),

    levels = require('enb-bem-techs/techs/levels'),
    levelsToBemdecl = require('enb-bem-techs/techs/levels-to-bemdecl'),
    files = require('enb-bem-techs/techs/files'),

    provide = require('enb/techs/file-provider'),
    depsByTechToBemdecl = require('enb-bem-techs/techs/deps-by-tech-to-bemdecl'),
    deps = require('enb-bem-techs/techs/deps'),
    depsOld = require('enb-bem-techs/techs/deps-old'),
    mergeDeps = require('enb-bem-techs/techs/merge-deps'),

    keysets = require('enb-bem-i18n/techs/keysets'),
    i18n = require('enb-bem-i18n/techs/i18n'),
    mockI18N = require('./techs/mock-lang-js'),
    mergeFile = require('enb/techs/file-merge'),

    references = require('./techs/references'),
    istanbul = require('./techs/istanbul'),
    spec = require('./techs/tmpl-spec'),
    instrumentedTarget = require('./util').instrumentedTarget;

exports.configure = function (config, options) {
    var pattern = path.join(options.destPath, '*'),
        coverageRe = new RegExp('/' + options.completeBundle + '$'),
        depsTech;

    if (typeof options.depsTech === 'function') {
        depsTech = options.depsTech;
    } else if (options.depsTech === 'deps') {
        depsTech = deps;
    } else {
        depsTech = depsOld;
    }

    config.nodes(pattern, function (nodeConfig) {
        var langs = options.langs,
            engines = options.engines,
            prependFiles = [].concat(options.prependFiles).filter(Boolean),
            appendFiles = [].concat(options.appendFiles).filter(Boolean),
            coverageEngines = options.coverage.engines,
            engineTargets = [],
            specTargets = [],
            nodePath = nodeConfig.getPath(),
            isCoverageBundle = coverageRe.test(nodePath),
            sourceLevels = [].concat(options.sourceLevels, options.sublevels[nodePath] || []);

        // Base techs
        nodeConfig.addTechs([
            [levels, { levels: sourceLevels }],
            [levels, { target: '?.base.levels', levels: options.levels }],
            [isCoverageBundle ? levelsToBemdecl : provide, {
                target: '?.base.bemdecl.js'
            }],
            [depsByTechToBemdecl, {
                target: '?.tech.bemdecl.js',
                filesTarget: '?.base.files',
                sourceTech: 'tmpl-spec.js'
            }],
            [mergeDeps, {
                target: '?.bemdecl.js',
                sources: ['?.base.bemdecl.js', '?.tech.bemdecl.js']
            }],
            [depsTech],
            [files, {
                levelsTarget: '?.base.levels',
                depsFile: '?.base.bemdecl.js',
                filesTarget: '?.base.files',
                dirsTarget: '?.base.dirs'
            }],
            [files]
        ]);

        // Provide prepending and appending files if any.
        prependFiles.concat(appendFiles)
            .forEach(function (filepath) {
                nodeConfig.addTech([provide, { target: filepath }]);
            });

        // Add engines' techs and set needsCoverage flag
        engines.forEach(function (engine) {
            engine.hasOwnProperty('needsCoverage') || (engine.needsCoverage = _.includes(coverageEngines, engine.name));
            nodeConfig.addTech([engine.tech, engine.options]);
        });

        // For each lang including no-lang (false) and mock-lang (true)
        (Array.isArray(langs) ? langs : [langs && 'mock']).forEach(function (lang) {
            var isMock = lang === 'mock',
                isReal = !isMock && typeof lang === 'string',
                suffix = '.' + (lang || 'merged') + '.js';

            // Keyset and lang file for real langs:
            isReal && nodeConfig.addTechs([
                [keysets, { lang: lang }],
                [i18n, { lang: lang, exports: { globals: 'force' } }]
            ]);

            // Mock for mock-lang:
            isMock && nodeConfig.addTechs([
                [mockI18N, { target: '?.lang' + suffix, mock: options.mockI18N }]
            ]);

            engines.forEach(function (engine) {
                var target = engine.target,
                    destTarget = target,
                    sources = []
                        .concat(prependFiles)
                        .concat(lang && ('?.lang' + suffix))
                        .concat(target)
{'fraction_non_alphanumeric': 0.14928240479150187, 'fraction_numerical': 0.0036162278223528083, 'mean_word_length': 1.913100724160632, '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': '3066849', 'n_tokens_mistral': 2776, 'n_tokens_neox': 2627, 'n_words': 450}