Skip to content

Commit

Permalink
Improved readability of CLI output and included number of passes/fail…
Browse files Browse the repository at this point in the history
…ures next to header
  • Loading branch information
basicallydan committed Aug 26, 2015
1 parent d87e67a commit 0e01003
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions index.js
Expand Up @@ -54,6 +54,8 @@ if (program.username && program.password) {
function listReporter(err, report) {
var successSymbol = '✓';
var badgeTypeText = '(success)'.green;
var suggestionsText = '(none)'.green;
var featuresText = '(none)'.yellow;

if (process.platform === 'win32') {
successSymbol = '√';
Expand All @@ -62,14 +64,32 @@ function listReporter(err, report) {
if (err) {
return console.error('Error: ', err.message);
}

// Customise the output a bit
if (report.failures.length > 0) {
featuresText = ('(' + report.passes.length + ')').magenta;
}

if (!report.failures.length) {
featuresText = ('(' + report.passes.length + ')').green;
}

if (report.failures.length > 0) {
suggestionsText = ('(' + report.failures.length + ')').yellow;
}

if (report.badge.type !== forkability.badgeTypes.ok) {
badgeTypeText = '(failure)'.red;
}

console.log('# Forkability found'.cyan, (report.passes.length + '').magenta, 'recommended features, and has'.cyan, (report.failures.length + '').magenta, 'suggestions'.cyan);
console.log('');
console.log('# Features'.magenta);
console.log('# Features'.magenta, featuresText);
report.passes.forEach(function(pass) {
console.log(successSymbol.green, pass.message);
});
console.log('');
console.log('# Suggestions'.magenta);
console.log('\n---\n');
console.log('# Suggestions'.magenta, suggestionsText);
report.failures.forEach(function(failure, i) {
var message = failure.message;
if (failure.details && failure.details.suggestion) {
Expand All @@ -80,11 +100,8 @@ function listReporter(err, report) {
console.log(((i === report.failures.length - 1 ? '└' : '├') + '──').cyan, failure.details.title ? (failure.details.title + ':') : '', failure.details.url.cyan);
}
});
console.log('');
if (report.badge.type !== forkability.badgeTypes.ok) {
badgeTypeText = '(failure)'.red;
}
console.log('# Forkability Badge'.cyan, badgeTypeText);
console.log('\n---\n');
console.log('# Forkability Badge'.magenta, badgeTypeText);
console.log('## Just the SVG:'.cyan, '\n' + report.badge.svg);
console.log('## Markdown:'.cyan, '\n' + report.badge.markdown);
console.log('## HTML:'.cyan, '\n' + report.badge.html);
Expand Down

0 comments on commit 0e01003

Please sign in to comment.