<commit_before>var path = require('path');
var fs = require('fs');

var prependFile = require('prepend-file');
var falafel = require('falafel');
var glob = require('glob');

var constants = require('./util/constants');

updateHeadersInSrcFiles();

// add headers to dist files

var pathsDist = [
    constants.pathToPlotlyDistMin,
    constants.pathToPlotlyDist,
    constants.pathToPlotlyDistWithMeta,
    constants.pathToPlotlyGeoAssetsDist
];

constants.partialBundleNames.forEach(function(name) {
    var pathToBundle = path.join(constants.pathToDist, 'plotly-' + name + '.js'),
        pathToMinBundle = path.join(constants.pathToDist, 'plotly-' + name + '.min.js');

    pathsDist.push(pathToBundle, pathToMinBundle);
});

function headerLicense(path) {
    prependFile(path, constants.licenseDist + '\n', function(err) {
        if(err) throw err;
    });
}

// add or update header to src/ lib/ files
function updateHeadersInSrcFiles() {
    var srcGlob = path.join(constants.pathToSrc, '**/*.js');
    var libGlob = path.join(constants.pathToLib, '**/*.js');
pathsDist.forEach(headerLicense);

    // remove leading '/*' and trailing '*/' for comparison with falafel output
    var licenseSrc = constants.licenseSrc;
    var licenseStr = licenseSrc.substring(2, licenseSrc.length - 2);

    glob('{' + srcGlob + ',' + libGlob + '}', function(err, files) {<commit_msg>tasks: add partial bundle name to dist headers<commit_after>var path = require('path');
var fs = require('fs');

var prependFile = require('prepend-file');
var falafel = require('falafel');
var glob = require('glob');

var constants = require('./util/constants');

// main
addHeadersInDistFiles();
updateHeadersInSrcFiles();

// add headers to dist files
function addHeadersInDistFiles() {
    function _prepend(path, header) {
        prependFile(path, header + '\n', function(err) {
            if(err) throw err;
        });
    }

    // add header to main dist bundles
    var pathsDist = [
        constants.pathToPlotlyDistMin,
        constants.pathToPlotlyDist,
        constants.pathToPlotlyDistWithMeta,
        constants.pathToPlotlyGeoAssetsDist
    ];
    pathsDist.forEach(function(path) {
        _prepend(path, constants.licenseDist);
    });

    // add header and bundle name to partial bundle
    constants.partialBundlePaths.forEach(function(pathObj) {
        var headerDist = constants.licenseDist
            .replace('plotly.js', 'plotly.js (' + pathObj.name + ')');
        _prepend(pathObj.dist, headerDist);

        var headerDistMin = constants.licenseDist
            .replace('plotly.js', 'plotly.js (' + pathObj.name + ' - minified)');
        _prepend(pathObj.distMin, headerDistMin);
    });
}

// add or update header to src/ lib/ files
function updateHeadersInSrcFiles() {
    var srcGlob = path.join(constants.pathToSrc, '**/*.js');
    var libGlob = path.join(constants.pathToLib, '**/*.js');

    // remove leading '/*' and trailing '*/' for comparison with falafel output
    var licenseSrc = constants.licenseSrc;
    var licenseStr = licenseSrc.substring(2, licenseSrc.length - 2);

    glob('{' + srcGlob + ',' + libGlob + '}', function(err, files) {
{'fraction_non_alphanumeric': 0.14069400630914827, 'fraction_numerical': 0.0012618296529968455, 'mean_word_length': 3.5890014471780027, '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': '5032369', 'n_tokens_mistral': 979, 'n_tokens_neox': 975, 'n_words': 220}