<commit_before>import chalk from 'chalk';
import { RuleToRuleApplicationResult } from './../types';
import logToConsole from './console';
import { compactProjectLogs } from './flatten';

export const consoleLogger = (projectResult: RuleToRuleApplicationResult): number => {
    const projectLogs = compactProjectLogs(projectResult);
    if (projectLogs.length) {
        console.log(chalk.bgBlackBright('Project'));
        logToConsole(projectLogs);
    }

    return projectLogs.length;
};<commit_msg>Return an error code equal to the number of errors found<commit_after>import chalk from 'chalk';
import { RuleToRuleApplicationResult } from './../types';
import logToConsole from './console';
import { compactProjectLogs } from './flatten';

export const consoleLogger = (projectResult: RuleToRuleApplicationResult): number => {
    const projectLogs = compactProjectLogs(projectResult);

    if (projectLogs.length) {
        console.log(chalk.bgBlackBright('Project'));
        logToConsole(projectLogs);
    }

    const errorCount = Object.values(projectLogs).reduce(
        (acc, i) => acc + ((i.errors && i.errors.length) || 0),
        0,
    );

    return errorCount;
};
{'fraction_non_alphanumeric': 0.12510566356720204, 'fraction_numerical': 0.0016906170752324597, 'mean_word_length': 4.081545064377682, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '2599279', 'n_tokens_mistral': 336, 'n_tokens_neox': 328, 'n_words': 82}