<commit_before>function Executor (exec) {
    this.execImpl = exec || require('child_process').exec;
    this.stopped = false;
}

Executor.prototype.exec = function(script) {
    if (this.stopped) {
        return;
    }

    this.stopped = false;

    var self = this;
    this.execImpl(script, function(error, stdout, stderr) {
        self.exec(script);
    });
};

Executor.prototype.stop = function() {
    this.stopped = true;
}

module.exports = Executor;


<commit_msg>On error, emit an error event with stdout/err<commit_after>var util = require("util");
var events = require("events");

function Executor (exec) {
    this.execImpl = exec || require('child_process').exec;
    this.stopped = false;
}

util.inherits(Executor, events.EventEmitter);

Executor.prototype.exec = function(script) {
    if (this.stopped) {
        return;
    }

    this.stopped = false;

    var self = this;
    this.execImpl(script, function(error, stdout, stderr) {
        if (error !== null) {
            self.emit('error', stdout, stderr);
            console.log(stdout, stderr);
        }
        self.exec(script);
    });
};

Executor.prototype.stop = function() {
    this.stopped = true;
}

module.exports = Executor;



{'fraction_non_alphanumeric': 0.14227309893704007, 'fraction_numerical': 0.0, 'mean_word_length': 2.8734177215189876, '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': '2525606', 'n_tokens_mistral': 396, 'n_tokens_neox': 389, 'n_words': 81}