1
0
mirror of https://github.com/bobwen-dev/react-templates synced 2025-04-12 00:56:39 +02:00

fix info print outs

This commit is contained in:
ido 2015-04-21 17:42:49 +03:00
parent 8e4af67439
commit 52412d99b0
2 changed files with 21 additions and 11 deletions

View File

@ -23,7 +23,7 @@ function convertFile(source, target, options, context) {
var fsUtil = require('./fsUtil'); var fsUtil = require('./fsUtil');
if (!options.force && !fsUtil.isStale(source, target)) { if (!options.force && !fsUtil.isStale(source, target)) {
context.info('target file ' + chalk.cyan(target) + ' is up to date, skipping'); context.info('target file ' + chalk.cyan(target) + ' is up to date, skipping', source);
return; return;
} }

View File

@ -34,9 +34,13 @@ function pluralize(word, count) {
// return n === 1 ? single : plural; // return n === 1 ? single : plural;
//} //}
//function lineText(line) { /**
// return line < 1 ? '' : line; * @param {number} line
//} * @return {string}
*/
function lineText(line) {
return line < 1 ? '' : line;
}
//module.exports = function (warnings/*, config*/) { //module.exports = function (warnings/*, config*/) {
// var _ = require('lodash'); // var _ = require('lodash');
@ -113,7 +117,8 @@ module.exports = function (results) {
total = 0, total = 0,
errors = 0, errors = 0,
warnings = 0, warnings = 0,
summaryColor = 'yellow'; infos = 0,
summaryColor = 'cyan';
_.each(results, function (result, k) { _.each(results, function (result, k) {
var messages = result; var messages = result;
@ -129,19 +134,23 @@ module.exports = function (results) {
messages.map(function (message) { messages.map(function (message) {
var messageType; var messageType;
if (message.fatal || message.severity === 2) { if (message.level === 'ERROR') {
messageType = chalk.red('error'); messageType = chalk.red('error');
summaryColor = 'red'; summaryColor = 'red';
errors++; errors++;
} else { } else if (message.level === 'WARN') {
messageType = chalk.yellow('warning'); messageType = chalk.yellow('warning');
summaryColor = 'yellow';
warnings++; warnings++;
} else {
messageType = chalk.cyan('info');
infos++;
} }
return [ return [
'', '',
message.line || 0, lineText(message.line),
message.column || 0, lineText(message.column),
messageType, messageType,
message.msg.replace(/\.$/, ''), message.msg.replace(/\.$/, ''),
chalk.gray(message.ruleId || '') chalk.gray(message.ruleId || '')
@ -162,9 +171,10 @@ module.exports = function (results) {
if (total > 0) { if (total > 0) {
output += chalk[summaryColor].bold([ output += chalk[summaryColor].bold([
'\u2716 ', total, pluralize(' problem', total), '\u2716 ', total, pluralize(' message', total),
' (', errors, pluralize(' error', errors), ', ', ' (', errors, pluralize(' error', errors), ', ',
warnings, pluralize(' warning', warnings), ')\n' warnings, pluralize(' warning', warnings), ', ',
infos, pluralize(' info', infos), ')\n'
].join('')); ].join(''));
} }