vfile-reporter
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -5,2 +5,8 @@ <!--remark setext--> | ||
2.0.1 / 2016-07-20 | ||
================== | ||
* Fix superfluous lines from showing up ([`e3dd9b2`](https://github.com/wooorm/vfile-reporter/commit/e3dd9b2)) | ||
* Fix a bug where the `color` setting wasn’t honoured ([`7904055`](https://github.com/wooorm/vfile-reporter/commit/7904055)) | ||
2.0.0 / 2016-06-23 | ||
@@ -7,0 +13,0 @@ ================== |
66
index.js
@@ -19,3 +19,4 @@ /** | ||
var symbols = require('log-symbols'); | ||
var chalk = require('chalk'); | ||
var Chalk = require('chalk').constructor; | ||
var strip = require('strip-ansi'); | ||
var table = require('text-table'); | ||
@@ -25,9 +26,2 @@ var repeat = require('repeat-string'); | ||
/* Map of no-warning messages, where `true` refers to | ||
* `compile: true`. */ | ||
var SUCCESS = { | ||
true: chalk.yellow('written'), | ||
false: 'no issues found' | ||
}; | ||
/* List of probable lengths of messages. */ | ||
@@ -104,2 +98,12 @@ var POSITION_LENGTH = '00:0-00:0'.length; | ||
/** | ||
* Check if a message is fatal. | ||
* | ||
* @param {VFileMessage} message - Message. | ||
* @return {boolean} - Whether `message` is `fatal`. | ||
*/ | ||
function fatal(message) { | ||
return message.fatal === true; | ||
} | ||
/** | ||
* @param {VFile|Array.<VFile>} files - One or more virtual | ||
@@ -123,2 +127,3 @@ * files. | ||
var defaultName = settings.defaultName || DEFAULT; | ||
var chalk = new Chalk({enabled: settings.color}); | ||
var fileCount = 0; | ||
@@ -148,2 +153,12 @@ var total = 0; | ||
files = files.filter(function (file) { | ||
var messages = file.messages; | ||
if (silent) { | ||
messages = messages.filter(fatal); | ||
} | ||
return !quiet || messages.length; | ||
}); | ||
files.forEach(function (file, position) { | ||
@@ -164,11 +179,5 @@ var destination = file.filePath(); | ||
if (silent) { | ||
messages = messages.filter(function (message) { | ||
return message.fatal === true; | ||
}); | ||
messages = messages.filter(fatal); | ||
} | ||
if (quiet && !messages.length) { | ||
return; | ||
} | ||
fileCount++; | ||
@@ -243,3 +252,4 @@ total += messages.length; | ||
} else { | ||
output += ': ' + SUCCESS[stored]; | ||
output += ': '; | ||
output += stored ? chalk.yellow('written') : 'no issues found'; | ||
} | ||
@@ -254,10 +264,6 @@ | ||
if (chalk.stripColor(line).slice(0, DEFAULT.length) === DEFAULT) { | ||
if (listing) { | ||
line = line.slice(line.indexOf('\n') + 1); | ||
} else { | ||
line = line.slice(line.indexOf(': ') + 2); | ||
} | ||
result[0] = line; | ||
if (strip(line).slice(0, DEFAULT.length) === DEFAULT) { | ||
result[0] = line.slice( | ||
listing ? line.indexOf('\n') + 1 : line.indexOf(': ') + 2 | ||
); | ||
} | ||
@@ -271,3 +277,3 @@ } | ||
summary.push([ | ||
symbols.error, | ||
chalk.red(strip(symbols.error)), | ||
errors, | ||
@@ -280,3 +286,3 @@ pluralize('error', errors) | ||
summary.push([ | ||
symbols.warning, | ||
chalk.yellow(strip(symbols.warning)), | ||
warnings, | ||
@@ -296,9 +302,3 @@ pluralize('warning', warnings) | ||
result = result.length ? result.join('\n') : ''; | ||
if (settings.color === false) { | ||
result = chalk.stripColor(result); | ||
} | ||
return result; | ||
return result.length ? result.join('\n') : ''; | ||
} | ||
@@ -305,0 +305,0 @@ |
{ | ||
"name": "vfile-reporter", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Stylish reporter for virtual files", | ||
@@ -31,2 +31,3 @@ "license": "MIT", | ||
"string-width": "^1.0.0", | ||
"strip-ansi": "^3.0.1", | ||
"text-table": "^0.2.0", | ||
@@ -33,0 +34,0 @@ "vfile-sort": "^1.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15001
246
8
+ Addedstrip-ansi@^3.0.1