* Expands exclude patterns by resolving symlinks in absolute path prefixes. * For each absolute pattern (starting with /), tries to resolve the longest * existing directory prefix via realpathSync and adds the resolved version. * Glob patterns (containing *) have their static prefix resolved.
(patterns: string[])
| 579 | * Glob patterns (containing *) have their static prefix resolved. |
| 580 | */ |
| 581 | function resolveExcludePatterns(patterns: string[]): string[] { |
| 582 | const fs = getFsImplementation() |
| 583 | const expanded: string[] = patterns.map(p => p.replaceAll('\\', '/')) |
| 584 | |
| 585 | for (const normalized of expanded) { |
| 586 | // Only resolve absolute patterns — glob-only patterns like "**/*.md" don't have |
| 587 | // a filesystem prefix to resolve |
| 588 | if (!normalized.startsWith('/')) { |
| 589 | continue |
| 590 | } |
| 591 | |
| 592 | // Find the static prefix before any glob characters |
| 593 | const globStart = normalized.search(/[*?{[]/) |
| 594 | const staticPrefix = |
| 595 | globStart === -1 ? normalized : normalized.slice(0, globStart) |
| 596 | const dirToResolve = dirname(staticPrefix) |
| 597 | |
| 598 | try { |
| 599 | // sync IO: called from sync context (isClaudeMdExcluded -> processMemoryFile -> getMemoryFiles) |
| 600 | const resolvedDir = fs.realpathSync(dirToResolve).replaceAll('\\', '/') |
| 601 | if (resolvedDir !== dirToResolve) { |
| 602 | const resolvedPattern = |
| 603 | resolvedDir + normalized.slice(dirToResolve.length) |
| 604 | expanded.push(resolvedPattern) |
| 605 | } |
| 606 | } catch { |
| 607 | // Directory doesn't exist; skip resolution for this pattern |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | return expanded |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * Recursively processes a memory file and all its @include references |
no test coverage detected