<commit_before>
var exec = require('child_process').exec,
    _ = require('underscore'),
    EventEmitter = require('events').EventEmitter;

/**
 * Run some commands in parallel
 * 
 * @param {Number} maxTasks
 * @param {Object} execOptions 
 */
function ParallelExec (maxTasks, execOptions) {
    var running = false,
        queue = [],
        runningTasks = 0;

    /**
     * Adds a task to the queue and starts the next task if there is space.
     *
     * @param {string} cmd
     */
    function addTask (cmd) {
        queue.push(cmd);

        if (running && runningTasks < maxTasks) {
            startNextTask();
        }
    }

    /**
     * Shift the next task from the queue and start it up
     */
    function startNextTask () {
        if (queue.length > 0) {
            var cmd = queue.shift();
            
            runningTasks++;
            this.emit('startedTask', cmd);
            exec(cmd, execOptions, _.partial(taskDone, cmd));
        }
    }

    /**
     * Decrement the running tasks and start the next one
     */
    function taskDone () {
        runningTasks--;
        this.emit('finishedTask', arguments);

        if (queue.length > 0) {
            startNextTask();
        }
        else {
            this.emit('finished', arguments);
        }
    }

    /**
     * Start the tasks running
     */
    function start () {
        running = true;

        _.times(maxTasks - runningTasks, startNextTask);
    }

    startNextTask = startNextTask.bind(this);
    taskDone = taskDone.bind(this);

    this.start = start;
    this.addTask = addTask;

    // inherit from event emitter
    EventEmitter.call(this);
}
<commit_msg>fixed a bug with the task complete output<commit_after>
var exec = require('child_process').exec,
    _ = require('underscore'),
    EventEmitter = require('events').EventEmitter;

/**
 * Run some commands in parallel
 *
 * @param {Number} maxTasks
 * @param {Object} execOptions
 */
function ParallelExec (maxTasks, execOptions) {
    var running = false,
        queue = [],
        runningTasks = 0;

    /**
     * Adds a task to the queue and starts the next task if there is space.
     *
     * @param {string} cmd
     */
    function addTask (cmd) {
        queue.push(cmd);

        if (running && runningTasks < maxTasks) {
            startNextTask();
        }
    }

    /**
     * Shift the next task from the queue and start it up
     */
    function startNextTask () {
        if (queue.length > 0) {
            var cmd = queue.shift();

            runningTasks++;
            this.emit('startedTask', cmd);
            exec(cmd, execOptions, _.partial(taskDone, cmd));
        }
    }

    /**
     * Decrement the running tasks and start the next one
     */
    function taskDone (err, stdout, stderr) {
        runningTasks--;
        this.emit('finishedTask', err, stdout, stderr);

        if (queue.length > 0) {
            startNextTask();
        }
        else {
            this.emit('finished');
        }
    }

    /**
     * Start the tasks running
     */
    function start () {
        running = true;

        _.times(maxTasks - runningTasks, startNextTask);
    }

    startNextTask = startNextTask.bind(this);
    taskDone = taskDone.bind(this);

    this.start = start;
    this.addTask = addTask;

    // inherit from event emitter
    EventEmitter.call(this);
}

{'fraction_non_alphanumeric': 0.11856889414547606, 'fraction_numerical': 0.0017740981667652277, 'mean_word_length': 1.8840579710144927, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5143191', 'n_tokens_mistral': 981, 'n_tokens_neox': 947, 'n_words': 263}