Skip to content

Commit d23e8ff

Browse files
committed
[api] added a filter mechanism to the walk function that will select folders that dont start with . and files with no extension, .js, .md, .markdown, .txt fles and readme files(i've seen a few to target)
1 parent f5419a3 commit d23e8ff

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,11 @@ function isNotOK(element, index, array) {
415415
return (element != 'OK');
416416
}
417417

418-
//function filterFiles(list){
419-
//var removeFromList = [ \\.git\g, '.*\.tar', '.*\.exe', '.*\.bin'];
420-
//}
418+
function filterString(str){
419+
var re = /^(\w*((\.js)|(\.txt)|(\.md)|(\.markdown))?|readme.*)$/gi;
420+
// only choose folders and no ext files, *.js, *.txt, *.md, *.markdown, and readme files
421+
return XRegExp.test(str, re);
422+
}
421423

422424
function walk(dir, done) {
423425
var results = [];
@@ -428,6 +430,8 @@ function walk(dir, done) {
428430
if (index >= 0){
429431
list.splice(index, 1);
430432
}
433+
var modList = list.filter(filterString);//filter out the undesirables
434+
list = modList;
431435
var pending = list.length;
432436
if (!pending){ return done(null, results);}
433437
list.forEach(function (file) {

0 commit comments

Comments
 (0)