fix(mage): do not check files in hidden directories

This commit is contained in:
kolaente 2025-03-18 21:21:53 +01:00
parent fafcda8dee
commit 737cf529ae
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 10 additions and 5 deletions

View File

@ -513,15 +513,20 @@ func flattenTranslations(prefix string, src map[string]interface{}, dest map[str
func walkCodebaseForTranslationKeys(rootDir string) ([]TranslationKey, error) {
var allKeys []TranslationKey
err := filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error {
pkgDir := filepath.Join(rootDir, "pkg")
err := filepath.Walk(pkgDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
// Skip non-Go files, vendor directory, and the contrib directory
if !info.IsDir() && strings.HasSuffix(path, ".go") &&
!strings.Contains(path, "/vendor/") &&
!strings.Contains(path, "/contrib/") {
// Skip hidden directories (starting with .)
if info.IsDir() && strings.HasPrefix(info.Name(), ".") {
return filepath.SkipDir
}
// Only process Go files
if !info.IsDir() && strings.HasSuffix(path, ".go") {
keys, err := extractTranslationKeysFromFile(path)
if err != nil {
fmt.Printf("Warning: %v\n", err)