<commit_before>// jme.queue.pipe_command.js

var ChildProcess = require('child_process');

var ExternalCommand = function(command, args, inputStream, exitFunction) {
        var instance = this;
        if (command === null) {
                return next();
        }
        var child = ChildProcess.spawn(command, args);
        instance.exit = 0;
        child.on('exit', function (code, signal) { exitFunction(code, signal, instance); });
        inputStream.pipe(child.stdin, {});
};

exports.hook_queue = function (next, connection) {
        var instance = this;
        var msg_stream = connection.transaction.message_stream;
        var notes = connection.transaction.notes;

        if(!notes.pipe) {
                next();
        }
        notes.discard = true;
        connection.loginfo(this, "Piping to external command: " + notes.pipeCommand);
        var pipedCommand = new ExternalCommand(
                notes.pipeCommand, notes.pipeArgs, msg_stream,
                function (code, signal, commandInstance) {
                        commandInstance.exit = 1;
                        connection.logdebug(instance, "Command complete: " + code + " " + signal);
                        next();
                }
        );
};<commit_msg>Added some ptions on the stream,<commit_after>// jme.queue.pipe_command.js

var ChildProcess = require('child_process');

var ExternalCommand = function(command, args, inputStream, exitFunction) {
        var instance = this;
        if (command === null) {
                return next();
        }
        var child = ChildProcess.spawn(command, args);
        instance.exit = 0;
        child.on('exit', function (code, signal) { exitFunction(code, signal, instance); });
        inputStream.pipe(child.stdin, {dot_stuffing: true, ending_dot: true});
};

exports.hook_queue = function (next, connection) {
        var instance = this;
        var msg_stream = connection.transaction.message_stream;
        var notes = connection.transaction.notes;

        if(!notes.pipe) {
                next();
        }
        notes.discard = true;
        connection.loginfo(this, "Piping to external command: " + notes.pipeCommand);

        connection.transaction.add_leading_header('Return-Path', transaction.mail_from.address());
        connection.transaction.add_leading_header('Envelope-To', connection.transaction.rcpt_to[0]);

        var pipedCommand = new ExternalCommand(
                notes.pipeCommand, notes.pipeArgs, msg_stream,
                function (code, signal, commandInstance) {
                        commandInstance.exit = 1;
                        connection.logdebug(instance, "Command complete: " + code + " " + signal);
                        next();
                }
        );
};
{'fraction_non_alphanumeric': 0.11420310805926996, 'fraction_numerical': 0.0018070112034694614, 'mean_word_length': 2.1706758304696447, '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': '2211024', 'n_tokens_mistral': 735, 'n_tokens_neox': 705, 'n_words': 163}