Skip to content
Closed
Changes from all commits
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
28 changes: 25 additions & 3 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] === '-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 All @@ -144,4 +166,4 @@ function quit(code){
} else {
process.exit(code || 0);
}
}
}