(folderPaths: string[])
| 105 | } |
| 106 | |
| 107 | export function findCommonAncestorFolder(folderPaths: string[]): string | undefined { |
| 108 | if (!folderPaths.length) |
| 109 | return undefined; |
| 110 | |
| 111 | const commonAncestorSegments = folderPaths[0].split(path.sep); |
| 112 | for (const folderPath of folderPaths.slice(1)) { |
| 113 | const pathSegments = folderPath.split(path.sep); |
| 114 | for (let i = 0; i < Math.min(commonAncestorSegments.length, pathSegments.length); i++) { |
| 115 | if (commonAncestorSegments[i] !== pathSegments[i]) { |
| 116 | commonAncestorSegments.splice(i); |
| 117 | break; |
| 118 | } |
| 119 | } |
| 120 | if (commonAncestorSegments.length > pathSegments.length) { |
| 121 | commonAncestorSegments.splice(pathSegments.length); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | // If we got up to the root, consider that not a match. |
| 126 | if (commonAncestorSegments.length <= 1) |
| 127 | return undefined; |
| 128 | |
| 129 | return commonAncestorSegments.join(path.sep); |
| 130 | } |
| 131 | |
| 132 | export async function getChildFolders(logger: Logger, parent: string, options?: { allowBin?: boolean; allowCache?: boolean }): Promise<string[]> { |
| 133 | if (!fs.existsSync(parent)) |
no outgoing calls
no test coverage detected