Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added a new command line flag for reducing verbosity
  • Loading branch information
dishad committed Aug 18, 2015
commit aa73844dcfe78fd5025ee77a0c97de6eb58700e6
26 changes: 24 additions & 2 deletions bin/htmlhint
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ program.on('--help', function(){
console.log(' htmlhint -l');
console.log(' htmlhint -r tag-pair,id-class-value=underline test.html');
console.log(' htmlhint -c .htmlhintrc test.html');
console.log(' htmlhint -s test.html');
console.log('');
});

Expand All @@ -32,14 +33,35 @@ program
.option('-l, --list', 'show all of the rules available.')
.option('-c, --config <file>', 'custom configuration file.')
.option('-r, --rules <ruleid, ruleid=value ...>', 'set all of the rules available.', map)
.option('-s, --suppress <file>', 'reduces verbosity within the linting process.')
.parse(process.argv);

if(program.list){
listRules();
quit(0);
}

var arrAllFiles = getAllFiles(program.args);
var noProblemSuppressed = 0;
var filePathArr;

if(process.argv[2] === '-l' || process.argv[2] === '-c' || process.argv[2] === '-l' || process.argv[2] === '-s'){
filePathArr = process.cwd() + '/' + process.argv[3];
}
else {
filePathArr = process.cwd() + '/' + process.argv[2];
}

var directoryFiles = [];

fs.readdirSync(filePathArr).forEach(function(fileName){
directoryFiles.push(filePathArr + '/' + fileName);
});

var arrAllFiles = getAllFiles(directoryFiles);

if(program.suppress){
noProblemSuppressed = 1;
}

var ruleset = program.rules;
if(ruleset === undefined){
Expand Down Expand Up @@ -117,7 +139,7 @@ function processFiles(arrFiles, ruleset){
if(allHintCount > 0){
console.log('\r\n%d problems.'.red, allHintCount);
}
else{
else if(noProblemSuppressed === 0) {
console.log('No problem.'.green);
}
return exitcode;
Expand Down