( dirs: readonly string[], fallback: string )
| 174 | } |
| 175 | |
| 176 | export const commonDirOf = ( |
| 177 | dirs: readonly string[], |
| 178 | fallback: string |
| 179 | ): string => { |
| 180 | const split = dirs.map(dir => tsPath(dir).replace(/\/+$/, "").split("/")) |
| 181 | const first = split[0] |
| 182 | if (!first?.length) return fallback |
| 183 | let common = 0 |
| 184 | while ( |
| 185 | common < first.length && |
| 186 | split.every(parts => parts[common] === first[common]) |
| 187 | ) |
| 188 | common++ |
| 189 | if (common === 0) return fallback |
| 190 | const joined = first.slice(0, common).join("/") |
| 191 | return /^[A-Za-z]:$/.test(joined) ? `${joined}/` : joined || "/" |
| 192 | } |
| 193 | |
| 194 | const mergeDeclarationResults = ( |
| 195 | results: Declarations[], |
no test coverage detected