From 67f24edb21911930b8b5b2ed20c7771178f2ae69 Mon Sep 17 00:00:00 2001 From: Jesus David Garcia Gomez Date: Fri, 12 May 2017 16:32:21 -0700 Subject: [PATCH] Stylish formatter report the total number of errors and warnings at the end Fix #201 --- src/lib/formatters/stylish/stylish.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib/formatters/stylish/stylish.ts b/src/lib/formatters/stylish/stylish.ts index 3ee8fd0..81ab239 100644 --- a/src/lib/formatters/stylish/stylish.ts +++ b/src/lib/formatters/stylish/stylish.ts @@ -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; @@ -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)}`)); } };