* 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[])
| 751 | * Glob patterns (containing *) have their static prefix resolved. |
| 752 | */ |
| 753 | function resolveExcludePatterns(patterns: string[]): string[] { |
| 754 | const fs = getFsImplementation() |
| 755 | const expanded: string[] = patterns.map(p => p.replaceAll('\\', '/')) |
| 756 | |
| 757 | for (const normalized of expanded) { |
| 758 | // Only resolve absolute patterns — glob-only patterns like "**/*.md" don't have |
| 759 | // a filesystem prefix to resolve |
| 760 | if (!normalized.startsWith('/')) { |
| 761 | continue |
| 762 | } |
| 763 | |
| 764 | // Find the static prefix before any glob characters |
| 765 | const globStart = normalized.search(/[*?{[]/) |
| 766 | const staticPrefix = |
| 767 | globStart === -1 ? normalized : normalized.slice(0, globStart) |
| 768 | const dirToResolve = dirname(staticPrefix) |
| 769 | |
| 770 | try { |
| 771 | // sync IO: called from sync context (isClaudeMdExcluded -> processMemoryFile -> getMemoryFiles) |
| 772 | const resolvedDir = fs.realpathSync(dirToResolve).replaceAll('\\', '/') |
| 773 | if (resolvedDir !== dirToResolve) { |
| 774 | const resolvedPattern = |
| 775 | resolvedDir + normalized.slice(dirToResolve.length) |
| 776 | expanded.push(resolvedPattern) |
| 777 | } |
| 778 | } catch { |
| 779 | // Directory doesn't exist; skip resolution for this pattern |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | return expanded |
| 784 | } |
| 785 | |
| 786 | /** |
| 787 | * Recursively processes a memory file and all its @include references |
no test coverage detected