<commit_before>var path = require('path'),
    _ = require('lodash'),
    File = require('vinyl'),
    eachInStream = require('../util/eachInStream');

module.exports = initPlugin;

var ORDER = ['setup', 'ym', 'plus', 'map', 'async', 'fallback', 'ready', 'namespace'];

var parts = [];

function initPlugin () {
    return eachInStream(processFile, createInitFile);
}

function processFile (file, _, cb) {
    if (file.relative.indexOf('init#') === 0) {
        var partName = file.relative.replace('init#', '');

        parts[ORDER.indexOf(partName)] = Buffer.concat([new Buffer('\n'), file.contents, new Buffer('\n')]);

        cb();
    } else {
        cb(null, file);
    }
}

function createInitFile (cb) {
    this.push(new File({
        path: path.join(process.cwd(), 'init.js'),
        contents: Buffer.concat(_.compact(parts))
    }));

    cb();
}<commit_msg>support for custom parts of init.js file<commit_after>var path = require('path'),
    _ = require('lodash'),
    File = require('vinyl'),
    eachInStream = require('../util/eachInStream');

module.exports = initPlugin;

var ORDER = ['setup', 'ym', 'plus', 'map', 'async', 'fallback', 'ready', 'namespace'];

var parts = [];

function initPlugin () {
    return eachInStream(processFile, createInitFile);
}

function processFile (file, _, cb) {
    if (file.relative.indexOf('init#') === 0) {
        var partName = file.relative.replace('init#', ''),
            index = ORDER.indexOf(partName);

        parts[index >= 0 ? index : parts.length] = Buffer.concat([new Buffer('\n'), file.contents, new Buffer('\n')]);

        cb();
    } else {
        cb(null, file);
    }
}

function createInitFile (cb) {
    this.push(new File({
        path: path.join(process.cwd(), 'init.js'),
        contents: Buffer.concat(_.compact(parts))
    }));

    cb();
}
{'fraction_non_alphanumeric': 0.19344262295081968, 'fraction_numerical': 0.001639344262295082, 'mean_word_length': 3.2581395348837208, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7219580', 'n_tokens_mistral': 587, 'n_tokens_neox': 573, 'n_words': 127}