Skip to content

Commit 00a3373

Browse files
author
jklein
committed
Adding the ability to exclude entire directories instead of just single files
1 parent 9c96c5b commit 00a3373

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

src/cli/common.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,29 @@ function cli(api){
6868

6969

7070
/**
71-
* Filters out files using the exclude-files command line option.
71+
* Filters out files using the exclude-list command line option.
7272
* @param files {Array} the list of files to check for exclusions
7373
* @param options {Object} the CLI options
7474
* @return {Array} A list of files
7575
*/
7676
function filterFiles(files, options) {
77-
var excludeFiles = options["exclude-files"],
77+
var excludeList = options["exclude-list"],
78+
excludeFiles = [],
7879
filesToLint = files;
7980

8081

81-
if (excludeFiles) {
82-
excludeFiles.split(",").forEach(function(value){
82+
if (excludeList) {
83+
// Build up the exclude list, expanding any directory exclusions that were passed in
84+
excludeList.split(",").forEach(function(value){
85+
if (api.isDirectory(value)) {
86+
excludeFiles = excludeFiles.concat(api.getFiles(value));
87+
} else {
88+
excludeFiles.push(value);
89+
}
90+
});
91+
92+
// Remove the excluded files from the list of files to lint
93+
excludeFiles.forEach(function(value){
8394
if (filesToLint.indexOf(value) > -1) {
8495
filesToLint.splice(filesToLint.indexOf(value),1);
8596
}
@@ -149,15 +160,15 @@ function cli(api){
149160
"\nUsage: csslint-rhino.js [options]* [file|dir]*",
150161
" ",
151162
"Global Options",
152-
" --help Displays this information.",
153-
" --format=<format> Indicate which format to use for output.",
154-
" --list-rules Outputs all of the rules available.",
155-
" --quiet Only output when errors are present.",
156-
" --errors=<rule[,rule]+> Indicate which rules to include as errors.",
157-
" --warnings=<rule[,rule]+> Indicate which rules to include as warnings.",
158-
" --ignore=<rule,[,rule]+> Indicate which rules to ignore completely.",
159-
" --exclude-files=<file,[,file]+> Indicate which files to exclude from being linted.",
160-
" --version Outputs the current version number."
163+
" --help Displays this information.",
164+
" --format=<format> Indicate which format to use for output.",
165+
" --list-rules Outputs all of the rules available.",
166+
" --quiet Only output when errors are present.",
167+
" --errors=<rule[,rule]+> Indicate which rules to include as errors.",
168+
" --warnings=<rule[,rule]+> Indicate which rules to include as warnings.",
169+
" --ignore=<rule[,rule]+> Indicate which rules to ignore completely.",
170+
" --exclude-list=<file|dir[,file|dir]+> Indicate which files/directories to exclude from being linted.",
171+
" --version Outputs the current version number."
161172
].join("\n") + "\n");
162173
}
163174

0 commit comments

Comments
 (0)