<commit_before>var colors = require('cli-color');
var check = require('check-types');
var formInstallCommand = require('./report-install-command');

var colorAvailable = process.stdout.isTTY;

function report(updates, useColors) {
    check.verifyArray(updates, 'expected array of updates');

    console.log('\nnext updates:');
    updates.forEach(function (moduleVersions) {
        reportModule(moduleVersions, useColors);
    });

    var cmd = formInstallCommand(updates);
    console.log('Use the following command to install working versions');
    console.log(cmd);
}

function reportModule(moduleVersions, useColors) {
    check.verifyArray(moduleVersions, 'expected module / versions array');
    if (!moduleVersions.length) {
        return;
    }
    useColors = !!useColors && colorAvailable;
    var name = moduleVersions[0].name;
    check.verifyString(name, 'missing module name from ' + JSON.stringify(moduleVersions));
    if (useColors) {
        var colorVersions = moduleVersions.map(function (info) {
            return (info.works ? colors.greenBright : colors.redBright)(info.version);
        });
        var str = colorVersions.join(', ');
        console.log(name + ' ' + str);
    } else {
        console.log(name);
        moduleVersions.forEach(function (info) {
            console.log('  ' + info.version + ' ' + (info.works ? 'PASS' : 'FAIL'));
        });
    }<commit_msg>handling case when nothing can be updated, fixes #59<commit_after>var colors = require('cli-color');
var check = require('check-types');
var formInstallCommand = require('./report-install-command');
var _ = require('lodash');

var colorAvailable = process.stdout.isTTY;

function report(updates, useColors) {
    check.verifyArray(updates, 'expected array of updates');

    console.log('\nnext updates:');
    updates.forEach(function (moduleVersions) {
        reportModule(moduleVersions, useColors);
    });

    var cmd = formInstallCommand(updates);
    if (_.isUndefined(cmd)) {
        console.log('Nothing can be updated :(');
    } else {
        console.log('Use the following command to install working versions');
        console.log(cmd);
    }
}

function reportModule(moduleVersions, useColors) {
    check.verifyArray(moduleVersions, 'expected module / versions array');
    if (!moduleVersions.length) {
        return;
    }
    useColors = !!useColors && colorAvailable;
    var name = moduleVersions[0].name;
    check.verifyString(name, 'missing module name from ' + JSON.stringify(moduleVersions));
    if (useColors) {
        var colorVersions = moduleVersions.map(function (info) {
            return (info.works ? colors.greenBright : colors.redBright)(info.version);
        });
        var str = colorVersions.join(', ');
        console.log(name + ' ' + str);
    } else {
        console.log(name);
        moduleVersions.forEach(function (info) {
            console.log('  ' + info.version + ' ' + (info.works ? 'PASS' : 'FAIL'));
        });
    }
{'fraction_non_alphanumeric': 0.1375041820006691, 'fraction_numerical': 0.0013382402141184342, 'mean_word_length': 3.2411347517730498, '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': '2169403', 'n_tokens_mistral': 857, 'n_tokens_neox': 863, 'n_words': 187}