Skip to content

Commit

Permalink
Merge pull request #47 from rmg/prune-exclusion
Browse files Browse the repository at this point in the history
Improve exclusion matching
  • Loading branch information
boyter authored Dec 19, 2018
2 parents 51a6000 + 4443ea0 commit ca77238
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions processor/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,16 @@ func walkDirectory(toWalk string, blackList []string, extensionLookup map[string
extension := ""
var filejobs []FileJob

var regex *regexp.Regexp
if Exclude != "" {
regex = regexp.MustCompile(Exclude)
}

godirwalk.Walk(toWalk, &godirwalk.Options{
// Unsorted is meant to make the walk faster and we need to sort after processing anyway
Unsorted: true,
Callback: func(root string, info *godirwalk.Dirent) error {

var regex *regexp.Regexp
if Exclude != "" {
regex = regexp.MustCompile(Exclude)
}

if Exclude != "" {
if regex.Match([]byte(info.Name())) {
if Verbose {
Expand All @@ -200,6 +200,9 @@ func walkDirectory(toWalk string, blackList []string, extensionLookup map[string
printWarn("skipping file due to match exclude: " + root)
}
}
if info.IsDir() {
return filepath.SkipDir
}
return nil
}
}
Expand Down

0 comments on commit ca77238

Please sign in to comment.