MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / resolveExcludePatterns

Function resolveExcludePatterns

source code/utils/claudemd.ts:583–614  ·  view source on GitHub ↗

* 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[])

Source from the content-addressed store, hash-verified

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

Callers 1

isClaudeMdExcludedFunction · 0.85

Calls 2

getFsImplementationFunction · 0.85
searchMethod · 0.80

Tested by

no test coverage detected