diff --git a/README.md b/README.md index bc1965af..be653ff7 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Flags: --debug Enable debug logging --exit-1-on-failure Exit with exit code 1 on failures -h, --help help for woke + --no-ignore Files matching entries in .gitignore/.wokeignore are parsed -o, --output string Output type [text,simple,github-actions] (default "text") --stdin Read from stdin -v, --version version for woke diff --git a/cmd/root.go b/cmd/root.go index d088b3e9..e8676ffb 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -45,6 +45,7 @@ var ( debug bool stdin bool output string + noIgnore bool // Version is populated by goreleaser during build // Version... @@ -83,9 +84,12 @@ Provide a list file globs for files you'd like to check.`, return err } - ignorer, err := ignore.NewIgnore(cfg.IgnoreFiles...) - if err != nil { - return err + var ignorer *ignore.Ignore + if !noIgnore { + ignorer, err = ignore.NewIgnore(cfg.IgnoreFiles...) + if err != nil { + return err + } } p := parser.NewParser(cfg.Rules, ignorer) @@ -135,6 +139,7 @@ func init() { rootCmd.PersistentFlags().BoolVar(&exitOneOnFailure, "exit-1-on-failure", false, "Exit with exit code 1 on failures") rootCmd.PersistentFlags().BoolVar(&stdin, "stdin", false, "Read from stdin") rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Enable debug logging") + rootCmd.PersistentFlags().BoolVar(&noIgnore, "no-ignore", false, "Files matching entries in .gitignore/.wokeignore are parsed") rootCmd.PersistentFlags().StringVarP(&output, "output", "o", printer.OutFormatText, fmt.Sprintf("Output type [%s]", printer.OutFormatsString)) } diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index e21fb102..9aa2e812 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -135,7 +135,7 @@ func (p *Parser) walkDir(dirname string, done <-chan struct{}) (<-chan string, < if !info.Mode().IsRegular() { return nil } - if p.Ignorer.Match(path) { + if p.Ignorer != nil && p.Ignorer.Match(path) { return nil } if util.IsTextFileFromFilename(path) != nil {