MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getDirectoriesToProcess

Function getDirectoriesToProcess

src/utils/attachments.ts:1656–1689  ·  view source on GitHub ↗
(
  targetPath: string,
  originalCwd: string,
)

Source from the content-addressed store, hash-verified

1654 * @returns Object with nestedDirs and cwdLevelDirs arrays, both ordered from parent to child
1655 */
1656export function getDirectoriesToProcess(
1657 targetPath: string,
1658 originalCwd: string,
1659): { nestedDirs: string[]; cwdLevelDirs: string[] } {
1660 // Build list of directories from original CWD to targetPath's directory
1661 const targetDir = dirname(resolve(targetPath))
1662 const nestedDirs: string[] = []
1663 let currentDir = targetDir
1664
1665 // Walk up from target directory to original CWD
1666 while (currentDir !== originalCwd && currentDir !== parse(currentDir).root) {
1667 if (currentDir.startsWith(originalCwd)) {
1668 nestedDirs.push(currentDir)
1669 }
1670 currentDir = dirname(currentDir)
1671 }
1672
1673 // Reverse to get order from CWD down to target
1674 nestedDirs.reverse()
1675
1676 // Build list of directories from root to CWD (for conditional rules only)
1677 const cwdLevelDirs: string[] = []
1678 currentDir = originalCwd
1679
1680 while (currentDir !== parse(currentDir).root) {
1681 cwdLevelDirs.push(currentDir)
1682 currentDir = dirname(currentDir)
1683 }
1684
1685 // Reverse to get order from root to CWD
1686 cwdLevelDirs.reverse()
1687
1688 return { nestedDirs, cwdLevelDirs }
1689}
1690
1691/**
1692 * Converts memory files to attachments, filtering out already-loaded files.

Callers 1

Calls 3

parseFunction · 0.85
resolveFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected