(workspaceDirectory string, libDirectory string, currentDirectory string, useCaseSensitiveFileNames bool)
| 269 | } |
| 270 | |
| 271 | func createResolutionLookupGlobMapper(workspaceDirectory string, libDirectory string, currentDirectory string, useCaseSensitiveFileNames bool) func(data *collections.SyncSet[tspath.Path]) PatternsAndIgnored { |
| 272 | workspaceDirectoryPath := tspath.ToPath(workspaceDirectory, currentDirectory, useCaseSensitiveFileNames) |
| 273 | currentDirectoryPath := tspath.ToPath(currentDirectory, currentDirectory, useCaseSensitiveFileNames) |
| 274 | libDirectoryPath := tspath.ToPath(libDirectory, currentDirectory, useCaseSensitiveFileNames) |
| 275 | |
| 276 | return func(data *collections.SyncSet[tspath.Path]) PatternsAndIgnored { |
| 277 | var ignored map[string]struct{} |
| 278 | var seenDirs collections.Set[tspath.Path] |
| 279 | var includeWorkspace, includeRoot, includeLib bool |
| 280 | var nodeModulesDirectories collections.Set[tspath.Path] |
| 281 | var externalDirectories collections.Set[tspath.Path] |
| 282 | |
| 283 | if data != nil { |
| 284 | data.Range(func(path tspath.Path) bool { |
| 285 | if tspath.IsDynamicFileName(string(path)) { |
| 286 | return true |
| 287 | } |
| 288 | // Assuming all of the input paths are file paths, we can avoid |
| 289 | // duplicate work by only taking one file per dir, since their outputs |
| 290 | // will always be the same. |
| 291 | if !seenDirs.AddIfAbsent(path.GetDirectoryPath()) { |
| 292 | return true |
| 293 | } |
| 294 | |
| 295 | if workspaceDirectoryPath.ContainsPath(path) { |
| 296 | includeWorkspace = true |
| 297 | } else if currentDirectoryPath.ContainsPath(path) { |
| 298 | includeRoot = true |
| 299 | } else if libDirectoryPath.ContainsPath(path) { |
| 300 | includeLib = true |
| 301 | } else if idx := strings.Index(string(path), "/node_modules/"); idx != -1 { |
| 302 | nodeModulesDirectories.Add(path[:idx+len("/node_modules")]) |
| 303 | } else { |
| 304 | externalDirectories.Add(path.GetDirectoryPath()) |
| 305 | } |
| 306 | return true |
| 307 | }) |
| 308 | } |
| 309 | |
| 310 | var globs []string |
| 311 | if includeWorkspace { |
| 312 | globs = append(globs, getRecursiveGlobPattern(string(workspaceDirectoryPath))) |
| 313 | } |
| 314 | if includeRoot { |
| 315 | globs = append(globs, getRecursiveGlobPattern(string(currentDirectoryPath))) |
| 316 | } |
| 317 | if includeLib { |
| 318 | globs = append(globs, getRecursiveGlobPattern(string(libDirectoryPath))) |
| 319 | } |
| 320 | if nodeModulesDirectories.Len() > 0 { |
| 321 | nodeModulesGlobs := make([]string, 0, nodeModulesDirectories.Len()) |
| 322 | for dir := range nodeModulesDirectories.Keys() { |
| 323 | nodeModulesGlobs = append(nodeModulesGlobs, getRecursiveGlobPattern(string(dir))) |
| 324 | } |
| 325 | slices.Sort(nodeModulesGlobs) |
| 326 | globs = append(globs, nodeModulesGlobs...) |
| 327 | } |
| 328 | var outsideDirs []string |
no test coverage detected