Skip to content

Commit

Permalink
Fix superfluous lines from showing up
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 20, 2016
1 parent 7904055 commit e3dd9b2
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ function point(position) {
return [position.line || 1, position.column || 1].join(':');
}

/**
* 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
* files.
Expand Down Expand Up @@ -136,6 +146,16 @@ function reporter(files, options) {
files = [files];
}

files = files.filter(function (file) {
var messages = file.messages;

if (silent) {
messages = messages.filter(fatal);
}

return !quiet || messages.length;
});

files.forEach(function (file, position) {
var destination = file.filePath();
var filePath = file.history[0] || destination;
Expand All @@ -151,13 +171,7 @@ function reporter(files, options) {
messages = file.messages;

if (silent) {
messages = messages.filter(function (message) {
return message.fatal === true;
});
}

if (quiet && !messages.length) {
return;
messages = messages.filter(fatal);
}

fileCount++;
Expand Down Expand Up @@ -241,13 +255,9 @@ function reporter(files, options) {
line = result[0];

if (strip(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;
result[0] = line.slice(
listing ? line.indexOf('\n') + 1 : line.indexOf(': ') + 2
);
}
}

Expand Down

0 comments on commit e3dd9b2

Please sign in to comment.