Skip to content

Commit f656e81

Browse files
committed
fix hidden support
1 parent 2841714 commit f656e81

4 files changed

Lines changed: 12 additions & 25 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Flags:
8181
-o, --output string output filename (default stdout)
8282
-p, --progress display progress of files as they are processed
8383
-r, --recursive recursive subdirectories are traversed
84+
--skip-hidden skip hidden files and directories
8485
--stream-size int min size of file in bytes where stream processing starts (default 1000000)
8586
--threads int number of threads processing files, by default the number of CPU cores (default 8)
8687
--trace enable trace output

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ func main() {
157157
false,
158158
"enable .gitmodules file logic",
159159
)
160+
161+
flags.BoolVar(
162+
&processor.SkipHidden,
163+
"skip-hidden",
164+
false, // Default to false, meaning hidden files are PROCESSED by default
165+
"skip hidden files and directories",
166+
)
160167
flags.StringSliceVar(
161168
&processor.PathDenyList,
162169
"exclude-dir",

processor/file.go

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,10 @@
33
package processor
44

55
import (
6-
"fmt"
76
"github.com/boyter/gocodewalker"
8-
"os"
9-
"path/filepath"
107
"regexp"
118
)
129

13-
func walkDirectory(toWalk string, output chan string) {
14-
15-
walkErr := filepath.WalkDir(toWalk, func(root string, info os.DirEntry, err error) error {
16-
if err != nil {
17-
return err
18-
}
19-
20-
if !info.IsDir() {
21-
output <- root
22-
}
23-
24-
return nil
25-
})
26-
27-
if walkErr != nil {
28-
if Verbose {
29-
printVerbose(fmt.Sprintf("error walking: %s", toWalk))
30-
}
31-
}
32-
}
33-
3410
func walkDirectoryWithIgnore(toWalk string, output chan string) {
3511
fileListQueue := make(chan *gocodewalker.File, 1000)
3612
var fileWalker *gocodewalker.FileWalker
@@ -45,7 +21,7 @@ func walkDirectoryWithIgnore(toWalk string, output chan string) {
4521
fileWalker.IgnoreGitIgnore = !GitIgnore
4622
fileWalker.IgnoreIgnoreFile = !Ignore
4723
fileWalker.IgnoreGitModules = !GitModuleIgnore
48-
fileWalker.IncludeHidden = true
24+
fileWalker.IncludeHidden = !SkipHidden
4925
fileWalker.ExcludeDirectory = PathDenyList
5026

5127
if HashIgnore {

processor/processor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ var Ignore = true
8383
// HashIgnore set true to enable hashignore file checks
8484
var HashIgnore = false
8585

86+
// SkipHidden set to false to ignore hidden folders and files
87+
var SkipHidden = true
88+
8689
// PathDenyList sets the paths that should be skipped
8790
var PathDenyList = []string{}
8891

0 commit comments

Comments
 (0)