add only frontend

This commit is contained in:
2026-08-27 14:20:33 +01:00
parent 1f5243d953
commit 2bbbf4e81e
5 changed files with 81 additions and 31 deletions
+27 -11
View File
@@ -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))