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

Function getDirectoriesToProcess

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

Source from the content-addressed store, hash-verified

1707 * @returns Object with nestedDirs and cwdLevelDirs arrays, both ordered from parent to child
1708 */
1709export function getDirectoriesToProcess(
1710 targetPath: string,
1711 originalCwd: string,
1712): { nestedDirs: string[]; cwdLevelDirs: string[] } {
1713 // Build list of directories from original CWD to targetPath's directory
1714 const targetDir = dirname(resolve(targetPath))
1715 const nestedDirs: string[] = []
1716 let currentDir = targetDir
1717
1718 // Walk up from target directory to original CWD
1719 while (currentDir !== originalCwd && currentDir !== parse(currentDir).root) {
1720 if (currentDir.startsWith(originalCwd)) {
1721 nestedDirs.push(currentDir)
1722 }
1723 currentDir = dirname(currentDir)
1724 }
1725
1726 // Reverse to get order from CWD down to target
1727 nestedDirs.reverse()
1728
1729 // Build list of directories from root to CWD (for conditional rules only)
1730 const cwdLevelDirs: string[] = []
1731 currentDir = originalCwd
1732
1733 while (currentDir !== parse(currentDir).root) {
1734 cwdLevelDirs.push(currentDir)
1735 currentDir = dirname(currentDir)
1736 }
1737
1738 // Reverse to get order from root to CWD
1739 cwdLevelDirs.reverse()
1740
1741 return { nestedDirs, cwdLevelDirs }
1742}
1743
1744/**
1745 * 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