( patternsByRoot: Map<string | null, string[]>, root: string, )
| 798 | } |
| 799 | |
| 800 | export function normalizePatternsToPath( |
| 801 | patternsByRoot: Map<string | null, string[]>, |
| 802 | root: string, |
| 803 | ): string[] { |
| 804 | // null root means the pattern can match anywhere |
| 805 | const result = new Set(patternsByRoot.get(null) ?? []) |
| 806 | |
| 807 | for (const [patternRoot, patterns] of patternsByRoot.entries()) { |
| 808 | if (patternRoot === null) { |
| 809 | // already added |
| 810 | continue |
| 811 | } |
| 812 | |
| 813 | // Check each pattern to see if the full path starts with our reference root |
| 814 | for (const pattern of patterns) { |
| 815 | const normalizedPattern = normalizePatternToPath({ |
| 816 | patternRoot, |
| 817 | pattern, |
| 818 | rootPath: root, |
| 819 | }) |
| 820 | if (normalizedPattern) { |
| 821 | result.add(normalizedPattern) |
| 822 | } |
| 823 | } |
| 824 | } |
| 825 | return Array.from(result) |
| 826 | } |
| 827 | |
| 828 | /** |
| 829 | * Collects all deny rules for file read permissions and returns their ignore patterns |
no test coverage detected