MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / getDirectoriesToProcess

Function getDirectoriesToProcess

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 2

resolveFunction · 0.70
parseFunction · 0.50

Tested by

no test coverage detected