expandDirectories replaces directory entries with their individual files recursively. It skips known junk directories and gitignored files.
(files []FileEntry, projectRoot string)
| 167 | // expandDirectories replaces directory entries with their individual files recursively. |
| 168 | // It skips known junk directories and gitignored files. |
| 169 | func expandDirectories(files []FileEntry, projectRoot string) []FileEntry { |
| 170 | seen := make(map[string]bool) |
| 171 | for _, f := range files { |
| 172 | seen[f.Path] = true |
| 173 | } |
| 174 | |
| 175 | var result []FileEntry |
| 176 | for _, f := range files { |
| 177 | fullPath := filepath.Join(projectRoot, f.Path) |
| 178 | info, err := os.Stat(fullPath) |
| 179 | if err != nil || !info.IsDir() { |
| 180 | result = append(result, f) |
| 181 | continue |
| 182 | } |
| 183 | expanded := walkDirectory(fullPath, projectRoot, f.Source, seen) |
| 184 | result = append(result, expanded...) |
| 185 | } |
| 186 | |
| 187 | return filterGitIgnored(result, projectRoot) |
| 188 | } |
| 189 | |
| 190 | // walkDirectory recursively collects files from a directory, skipping known junk directories. |
| 191 | func walkDirectory(dir, projectRoot, source string, seen map[string]bool) []FileEntry { |
no test coverage detected