<commit_before>var mout = require('mout');

var sizes = {
    tag: 10,   // Tag max chars
    label: 23, // Label max chars
    sumup: 5   // Amount to sum when the label exceeds
};
var tagColors = {
    'warn': 'yellow',
    'error': 'red',
    'default': 'cyan'
};

function isCompact() {
    return process.stdout.columns < 120;
}

function uncolor(str) {
    return str.replace(/\x1B\[\d+m/g, '');
}

function renderTagPlusLabel(data) {
    var label;
    var length;
    var nrSpaces;
    var tag = data.tag;
    var tagColor = tagColors[data.level] || tagColors['default'];

    // If there's not enough space, print only the tag
    if (isCompact()) {
        return mout.string.rpad(tag, sizes.tag)[tagColor];
    }

    label = data.origin + '#' + data.endpoint.target;
    length = tag.length + label.length + 1;
    nrSpaces = sizes.tag + sizes.label - length;

    // Ensure at least one space between the label and the tag
    if (nrSpaces < 1) {
        sizes.label = label.length + sizes.sumup;
        nrSpaces = sizes.tag + sizes.label - length;
    }


    return label.green + mout.string.repeat(' ', nrSpaces) + tag[tagColor];
}

// -------------------------

var colorful = {
    begin: function () {},
    end: function () {},
    error: function (err) {
        var str;

        str = 'bower ' + renderTagPlusLabel(err) + ' ' + (err.code ? err.code + ' ,' : '') + err.message + '\n';

        // Check if additional details were provided
        if (err.details) {
            str += err.details + '\n';
        }

        // Print stack
        str += '\n' + err.stack + '\n';

        this._write(process.stderr, str);
    },
    data: function (data) {
        data.data = data.data || '';

        this._write(process.stdout, 'bower ' + renderTagPlusLabel(data) + ' ' + data.data + '\n');
    },
    checkout: function (data) {
        if (isCompact()) {
            data.data = data.origin + '#' + data.data;
        }<commit_msg>Make warnings go out on stderr<commit_after>var mout = require('mout');

var sizes = {
    tag: 10,   // Tag max chars
    label: 23, // Label max chars
    sumup: 5   // Amount to sum when the label exceeds
};
var tagColors = {
    'warn': 'yellow',
    'error': 'red',
    'default': 'cyan'
};

function isCompact() {
    return process.stdout.columns < 120;
}

function uncolor(str) {
    return str.replace(/\x1B\[\d+m/g, '');
}

function renderTagPlusLabel(data) {
    var label;
    var length;
    var nrSpaces;
    var tag = data.tag;
    var tagColor = tagColors[data.level] || tagColors['default'];

    // If there's not enough space, print only the tag
    if (isCompact()) {
        return mout.string.rpad(tag, sizes.tag)[tagColor];
    }

    label = data.origin + '#' + data.endpoint.target;
    length = tag.length + label.length + 1;
    nrSpaces = sizes.tag + sizes.label - length;

    // Ensure at least one space between the label and the tag
    if (nrSpaces < 1) {
        sizes.label = label.length + sizes.sumup;
        nrSpaces = sizes.tag + sizes.label - length;
    }


    return label.green + mout.string.repeat(' ', nrSpaces) + tag[tagColor];
}

// -------------------------

var colorful = {
    begin: function () {},
    end: function () {},
    error: function (err) {
        var str;

        str = 'bower ' + renderTagPlusLabel(err) + ' ' + (err.code ? err.code + ' ,' : '') + err.message + '\n';

        // Check if additional details were provided
        if (err.details) {
            str += err.details + '\n';
        }

        // Print stack
        str += '\n' + err.stack + '\n';

        this._write(process.stderr, str);
    },
    data: function (data) {
        data.data = data.data || '';

        var outputStream = process.stdout;

        if (data.level === 'warn') {
            outputStream = process.stderr;
        }

        this._write(outputStream, 'bower ' + renderTagPlusLabel(data) + ' ' + data.data + '\n');
    },
    checkout: function (data) {
        if (isCompact()) {
            data.data = data.origin + '#' + data.data;
        }
{'fraction_non_alphanumeric': 0.16642084562438544, 'fraction_numerical': 0.005408062930186824, 'mean_word_length': 2.05709992486852, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5590185', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1302, 'n_words': 337}