( targetPath: string, originalCwd: string, )
| 1707 | * @returns Object with nestedDirs and cwdLevelDirs arrays, both ordered from parent to child |
| 1708 | */ |
| 1709 | export 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. |
no test coverage detected