(repoRoot, relSegments, rawPattern)
| 626 | } |
| 627 | |
| 628 | function projectRootFromWorkspacePattern(repoRoot, relSegments, rawPattern) { |
| 629 | const pattern = normalizeWorkspacePattern(rawPattern); |
| 630 | if (!pattern || pattern.startsWith('!')) return null; |
| 631 | const patternSegments = pattern.split('/').filter(Boolean); |
| 632 | if (!patternSegments.length) return null; |
| 633 | if (patternSegments.includes('**')) { |
| 634 | return projectRootFromDoubleStarPattern(repoRoot, relSegments, patternSegments); |
| 635 | } |
| 636 | if (relSegments.length < patternSegments.length) return null; |
| 637 | for (let i = 0; i < patternSegments.length; i++) { |
| 638 | if (!segmentMatches(patternSegments[i], relSegments[i])) return null; |
| 639 | } |
| 640 | return path.join(repoRoot, ...relSegments.slice(0, patternSegments.length)); |
| 641 | } |
| 642 | |
| 643 | function projectRootFromDoubleStarPattern(repoRoot, relSegments, patternSegments) { |
| 644 | const firstGlobIndex = patternSegments.findIndex((segment) => segment.includes('*')); |
no test coverage detected