Skip to content

Commit

Permalink
Stylish formatter report the total number of errors and warnings at t…
Browse files Browse the repository at this point in the history
…he end

Fix #201
  • Loading branch information
sarvaje committed May 12, 2017
1 parent 42dc706 commit 67f24ed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib/formatters/stylish/stylish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ const formatter: IFormatter = {

debug('Formatting results');

if (messages.length === 0) {
return;
}

const resources = _.groupBy(messages, 'resource');
let totalErrors = 0;
let totalWarnings = 0;

_.forEach(resources, (msgs, resource) => {
let warnings = 0;
Expand All @@ -57,9 +63,16 @@ const formatter: IFormatter = {

const color = errors > 0 ? chalk.red : chalk.yellow;

totalErrors += errors;
totalWarnings += warnings;

logger.log(color.bold(`\u2716 Found ${errors} ${pluralize('error', errors)} and ${warnings} ${pluralize('warning', warnings)}`));
logger.log('');
});

const color = totalErrors > 0 ? chalk.red : chalk.yellow;

logger.log(color.bold(`\u2716 Found a total of ${totalErrors} ${pluralize('error', totalErrors)} and ${totalWarnings} ${pluralize('warning', totalWarnings)}`));
}
};

Expand Down

0 comments on commit 67f24ed

Please sign in to comment.