Skip to content

Commit

Permalink
Merge pull request #86 from hail2u/gnu
Browse files Browse the repository at this point in the history
Add `gnu` custom output format
  • Loading branch information
yaniswang committed Oct 25, 2015
2 parents 365d49b + d92990d commit c9e2152
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions bin/htmlhint
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ program
.option('-c, --config <file>', 'custom configuration file')
.option('-r, --rules <ruleid, ruleid=value ...>', 'set all of the rules available', map)
.option('-p, --plugin <file|folder>', 'load custom rules from file or folder')
.option('-f, --format <json|junit|checkstyle>', 'output messages as custom format')
.option('-f, --format <json|junit|checkstyle|unix>', 'output messages as custom format')
.option('-i, --ignore <pattern, pattern ...>', 'add pattern to exclude matches')
.parse(process.argv);

Expand Down Expand Up @@ -176,8 +176,11 @@ function formatResult(hintInfo, format){
case 'checkstyle':
formatCheckstyle(hintInfo);
break;
case 'unix':
formatUnix(hintInfo);
break;
default:
console.log('No supported format, supported format:json, junit, checkstyle.'.red);
console.log('No supported format, supported format:json, junit, checkstyle, unix.'.red);
process.exit(1);
}
}
Expand Down Expand Up @@ -275,6 +278,22 @@ function formatCheckstyle(hintInfo){
}));
}

// format as unix style
function formatUnix(hintInfo){
hintInfo.arrAllMessages.forEach(function (fileInfo) {
var file = path.relative(process.cwd(), fileInfo.file);
fileInfo.messages.forEach(function (message) {
console.log([
file,
message.line,
message.col,
" " + message.type,
" " + message.message
].join(":"));
});
});
}

// hint all files
function hintAllFiles(target, options, onFinised){
var globInfo = getGlobInfo(target);
Expand Down

0 comments on commit c9e2152

Please sign in to comment.