add only frontend
This commit is contained in:
+27
-11
@@ -1,17 +1,19 @@
|
||||
// internal/filter/filter.go
|
||||
package filter
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"dirmd/internal/config"
|
||||
)
|
||||
|
||||
type Filter struct {
|
||||
MaxSize int64
|
||||
Extensions []string
|
||||
Ignores []string
|
||||
OmitTest bool
|
||||
MaxSize int64
|
||||
Extensions []string
|
||||
Ignores []string
|
||||
OmitTest bool
|
||||
FrontendOnly bool
|
||||
}
|
||||
|
||||
func (f *Filter) ShouldSkipDir(name string) bool {
|
||||
@@ -39,14 +41,11 @@ func (f *Filter) ShouldSkipFile(path, name string, info os.FileInfo) bool {
|
||||
}
|
||||
}
|
||||
|
||||
ext := filepath.Ext(path)
|
||||
for _, bad := range f.Extensions {
|
||||
if strings.EqualFold(ext, bad) {
|
||||
return true
|
||||
}
|
||||
if info.Size() > f.MaxSize {
|
||||
return true
|
||||
}
|
||||
|
||||
if info.Size() > f.MaxSize {
|
||||
if f.FrontendOnly && !isFrontendOrReadme(path, name) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -54,9 +53,26 @@ func (f *Filter) ShouldSkipFile(path, name string, info os.FileInfo) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
ext := filepath.Ext(path)
|
||||
for _, bad := range f.Extensions {
|
||||
if strings.EqualFold(ext, bad) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func isFrontendOrReadme(path, name string) bool {
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
for _, fe := range config.FrontendExts {
|
||||
if strings.EqualFold(ext, fe) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return strings.EqualFold(name, "README.md")
|
||||
}
|
||||
|
||||
func isTestFile(path, name string) bool {
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user