Filter dot files etc. in i18n

Closes #11993
This commit is contained in:
Bjørn Erik Pedersen
2024-02-05 14:54:02 +01:00
parent c37bf19c89
commit 9df7b295bc
5 changed files with 38 additions and 14 deletions

View File

@@ -53,8 +53,9 @@ type WalkwayConfig struct {
Logger loggers.Logger
// One or both of these may be pre-set.
Info FileMetaInfo // The start info.
DirEntries []FileMetaInfo // The start info's dir entries.
Info FileMetaInfo // The start info.
DirEntries []FileMetaInfo // The start info's dir entries.
IgnoreFile func(filename string) bool // Optional
// Will be called in order.
HookPre WalkHook // Optional.
@@ -172,6 +173,17 @@ func (w *Walkway) walk(path string, info FileMetaInfo, dirEntries []FileMetaInfo
}
if w.cfg.IgnoreFile != nil {
n := 0
for _, fi := range dirEntries {
if !w.cfg.IgnoreFile(fi.Meta().Filename) {
dirEntries[n] = fi
n++
}
}
dirEntries = dirEntries[:n]
}
if w.cfg.HookPre != nil {
var err error
dirEntries, err = w.cfg.HookPre(info, path, dirEntries)