<commit_before>var _ = require('lodash'),
    prettyms = require('pretty-ms'),
    colors = require('colors/safe'),
    Table = require('cli-table2'),
    format = require('util').format,

    cliUtils = require('./cli-utils'),
    print = require('./print'),
    pad = cliUtils.padLeft,

    LF = '\n',
    SPC = ' ',
    E = '',

    /**
     * Helper function to get parent of an item
     *
     * @param {PostmanItem} item
     * @returns {PostmanItemGroup}
     */
    parentOf = function (item) {
        return item && item.__parent && item.__parent.__parent || undefined;
    };

module.exports = function PostmanCLIReporter (emitter, options) {
    var currentGroup = options.collection;

    emitter.on('start', function () {
        // print the collection name and newman infoline
        print.lf('%s\n\n%s', colors.reset('newman'), colors.reset(currentGroup.name));
    });

    emitter.on('beforeIteration', function (err, o) {
        if (err || o.cursor.cycles <= 1) {
            return; // do not print iteration banner if it is a single iteration run
        }

        // print the iteration infoline
        print.lf(LF + colors.gray.underline('Iteration %d/%d') + LF, o.cursor.iteration + 1, o.cursor.cycles);
    });

    emitter.on('beforeItem', function (err, o) {
        var itemGroup = parentOf(o.item),
            root = !itemGroup || (itemGroup === options.collection);

        // in case this item belongs to a separate folder, print that folder name
        if (itemGroup && (currentGroup !== itemGroup)) {

            // we only print if the request is not directly under collection. no point printing collection name
            // again and again
            !root && print.lf('\n❏ %s', colors.reset(itemGroup.name));

            // set the flag that keeps track of the currently running group
            currentGroup = itemGroup;
        }

        // we print the item name. the symbol prefix denotes if the item is in root or under folder.
        // @todo - when we do indentation, we would not need symbolic representation
        o.item && print.lf('%s %s', (root ? '→' : '↳'), colors.reset(o.item.name || E));
    });

    // print out the request name to be executed and start a spinner
    emitter.on('beforeRequest', function (err, o) {
        o.request && print('  %s %s ', colors.gray(o.request.method), colors.gray(o.request.url)).wait();
    });

    // output the response code, reason and time
    emitter.on('request', function (err, o) {
        err ? print.lf(colors.red('[errored]')) :
            print.lf(colors.gray('[%s %d, %s]'), o.response.reason(), o.response.code,
                prettyms(o.response.responseTime));
    });

    // realtime print out script errors
    emitter.on('script', function (err, o) {
        err && print.lf(colors.red.bold('%s⠄ %s in %s script'), pad(this.summary.failures.length, 3, SPC), err.name,
            o.event && o.event.listen || '<unknown-script>');
    });

    emitter.on('assertion', function (err, o) {
        var passed = !err;

        // print each test assertions
        print.lf('%s %s', passed ? colors.green('  ✔ ') : colors.red.bold(pad(this.summary.failures.length, 3, SPC) +
            '⠄'), passed ? colors.gray(o.assertion) : colors.red.bold(o.assertion));
    });

    emitter.on('done', function () {
        var summary = this.summary,
            failures = summary.failures,
            failureFaceValue = Number(failures.length.toString().length),
            failureTable,
            summaryTable;<commit_msg>Printing 200 OK instead of OK 200 in the response log<commit_after>var _ = require('lodash'),
    prettyms = require('pretty-ms'),
    colors = require('colors/safe'),
    Table = require('cli-table2'),
    format = require('util').format,

    cliUtils = require('./cli-utils'),
    print = require('./print'),
    pad = cliUtils.padLeft,

    LF = '\n',
    SPC = ' ',
    E = '',

    /**
     * Helper function to get parent of an item
     *
     * @param {PostmanItem} item
     * @returns {PostmanItemGroup}
     */
    parentOf = function (item) {
        return item && item.__parent && item.__parent.__parent || undefined;
    };

module.exports = function PostmanCLIReporter (emitter, options) {
    var currentGroup = options.collection;

    emitter.on('start', function () {
        // print the collection name and newman infoline
        print.lf('%s\n\n%s', colors.reset('newman'), colors.reset(currentGroup.name));
    });

    emitter.on('beforeIteration', function (err, o) {
        if (err || o.cursor.cycles <= 1) {
            return; // do not print iteration banner if it is a single iteration run
        }

        // print the iteration infoline
        print.lf(LF + colors.gray.underline('Iteration %d/%d') + LF, o.cursor.iteration + 1, o.cursor.cycles);
    });

    emitter.on('beforeItem', function (err, o) {
        var itemGroup = parentOf(o.item),
            root = !itemGroup || (itemGroup === options.collection);

        // in case this item belongs to a separate folder, print that folder name
        if (itemGroup && (currentGroup !== itemGroup)) {

            // we only print if the request is not directly under collection. no point printing collection name
            // again and again
            !root && print.lf('\n❏ %s', colors.reset(itemGroup.name));

            // set the flag that keeps track of the currently running group
            currentGroup = itemGroup;
        }

        // we print the item name. the symbol prefix denotes if the item is in root or under folder.
        // @todo - when we do indentation, we would not need symbolic representation
        o.item && print.lf('%s %s', (root ? '→' : '↳'), colors.reset(o.item.name || E));
    });

    // print out the request name to be executed and start a spinner
    emitter.on('beforeRequest', function (err, o) {
        o.request && print('  %s %s ', colors.gray(o.request.method), colors.gray(o.request.url)).wait();
    });

    // output the response code, reason and time
    emitter.on('request', function (err, o) {
        err ? print.lf(colors.red('[errored]')) :
            print.lf(colors.gray('[%d %s, %s]'), o.response.code, o.response.reason(),
                prettyms(o.response.responseTime));
    });

    // realtime print out script errors
    emitter.on('script', function (err, o) {
        err && print.lf(colors.red.bold('%s⠄ %s in %s script'), pad(this.summary.failures.length, 3, SPC), err.name,
            o.event && o.event.listen || '<unknown-script>');
    });

    emitter.on('assertion', function (err, o) {
        var passed = !err;

        // print each test assertions
        print.lf('%s %s', passed ? colors.green('  ✔ ') : colors.red.bold(pad(this.summary.failures.length, 3, SPC) +
            '⠄'), passed ? colors.gray(o.assertion) : colors.red.bold(o.assertion));
    });

    emitter.on('done', function () {
        var summary = this.summary,
            failures = summary.failures,
            failureFaceValue = Number(failures.length.toString().length),
            failureTable,
            summaryTable;
{'fraction_non_alphanumeric': 0.14942528735632185, 'fraction_numerical': 0.00224278104850014, 'mean_word_length': 2.402479732951836, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3713282', 'n_tokens_mistral': 2152, 'n_tokens_neox': 2058, 'n_words': 591}