matchesPattern does smart pattern matching: - ".png" or "png" → extension match (case-insensitive) - "Fonts" → directory/component match (contains /Fonts/ or ends with /Fonts) - "*test*" → glob pattern (only if contains * or ?)
(relPath string, pattern string)
| 142 | // - "Fonts" → directory/component match (contains /Fonts/ or ends with /Fonts) |
| 143 | // - "*test*" → glob pattern (only if contains * or ?) |
| 144 | func matchesPattern(relPath string, pattern string) bool { |
| 145 | // If pattern contains glob characters, use glob matching |
| 146 | if strings.ContainsAny(pattern, "*?") { |
| 147 | // Match against filename |
| 148 | if matched, _ := filepath.Match(pattern, filepath.Base(relPath)); matched { |
| 149 | return true |
| 150 | } |
| 151 | // Match against full relative path |
| 152 | if matched, _ := filepath.Match(pattern, relPath); matched { |
| 153 | return true |
| 154 | } |
| 155 | return false |
| 156 | } |
| 157 | |
| 158 | // Extension match: .png, .xcassets, png, xcassets |
| 159 | ext := strings.TrimPrefix(pattern, ".") |
| 160 | if strings.HasSuffix(strings.ToLower(relPath), "."+strings.ToLower(ext)) { |
| 161 | return true |
| 162 | } |
| 163 | |
| 164 | // Directory component match: Fonts → matches path/Fonts/file or path/Fonts |
| 165 | if strings.Contains(relPath, "/"+pattern+"/") || |
| 166 | strings.HasSuffix(relPath, "/"+pattern) || |
| 167 | strings.HasPrefix(relPath, pattern+"/") || |
| 168 | relPath == pattern { |
| 169 | return true |
| 170 | } |
| 171 | |
| 172 | return false |
| 173 | } |
| 174 | |
| 175 | // shouldIncludeFile checks if a file passes the only/exclude filters |
| 176 | func shouldIncludeFile(relPath string, ext string, only []string, exclude []string) bool { |
no outgoing calls