<commit_before>'use strict';
var defaults = require('../data/defaults');
var lodash = require('lodash');
var reverseConfig = require('reverse-config');
var packageName = require('../package').name;

function expand(array) {
    var bundles = {};
    array.forEach(function (bundle) {
        if ('string' == typeof bundle) {
            bundles[bundle] = {};
        } else {
            lodash.merge(bundles, bundle);
        }
    });
    return bundles;
}

function sourceExpression(input) {
    var expression;

    if ('/' !== input.charAt(input.length)) {
        input += '/';
    }

    expression = input
        .replace(/^\.\//, '')
        .replace(/\//g, '[\\/\\\\]');

    return new RegExp(expression);
}

function mergeConfig(options) {
    var config = JSON.parse(JSON.stringify(defaults));
    var moduleConfig = reverseConfig.get(packageName);

    function setConfig(key) {
        config[key] = moduleConfig[key];
    }

    function setOption(key) {
        // runtime options can't overwrite package config options
        if (moduleConfig && moduleConfig.hasOwnProperty(key)) {
            throw new Error('Refusing to overwrite `' + key + '`');
        }

        config[key] = options[key];
    }

    if (moduleConfig) {
        Object.keys(moduleConfig).forEach(setConfig);
    }

    if (options) {
        Object.keys(options).forEach(setOption);
    }

    if (Array.isArray(config.bundles)) {
        config.bundles = expand(config.bundles);
    }

    config.babel = [
        /node_modules[\/\\]_app[\/\\]/,
        sourceExpression(config.source)
    ];

    return config;
}

module.exports = mergeConfig;<commit_msg>Add babel config option<commit_after>'use strict';
var defaults = require('../data/defaults');
var lodash = require('lodash');
var reverseConfig = require('reverse-config');
var packageName = require('../package').name;

function expand(array) {
    var bundles = {};
    array.forEach(function (bundle) {
        if ('string' == typeof bundle) {
            bundles[bundle] = {};
        } else {
            lodash.merge(bundles, bundle);
        }
    });
    return bundles;
}

function sourceExpression(input) {
    var expression;

    if ('/' !== input.charAt(input.length)) {
        input += '/';
    }

    expression = input
        .replace(/^\.\//, '')
        .replace(/\//g, '[\\/\\\\]');

    return new RegExp(expression);
}

function mergeConfig(options) {
    var config = JSON.parse(JSON.stringify(defaults));
    var moduleConfig = reverseConfig.get(packageName);

    function setConfig(key) {
        config[key] = moduleConfig[key];
    }

    function setOption(key) {
        // runtime options can't overwrite package config options
        if (moduleConfig && moduleConfig.hasOwnProperty(key)) {
            throw new Error('Refusing to overwrite `' + key + '`');
        }

        config[key] = options[key];
    }

    if (moduleConfig) {
        Object.keys(moduleConfig).forEach(setConfig);
    }

    if (options) {
        Object.keys(options).forEach(setOption);
    }

    if (Array.isArray(config.bundles)) {
        config.bundles = expand(config.bundles);
    }

    config.babel = [
        /node_modules[\/\\]_app[\/\\]/,
        sourceExpression(config.source || config.babel)
    ];

    return config;
}

module.exports = mergeConfig;
{'fraction_non_alphanumeric': 0.15816326530612246, 'fraction_numerical': 0.0, 'mean_word_length': 2.4114636642784033, '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': '6503830', 'n_tokens_mistral': 996, 'n_tokens_neox': 955, 'n_words': 189}