| 2770 | // `tests/x.py` (`**` matches zero folders). Dotfiles count. picomatch is |
| 2771 | // loaded here, not at startup, since only this command needs it. |
| 2772 | async function affectedFilterMatcher(pattern: string): Promise<(filePath: string) => boolean> { |
| 2773 | const { default: picomatch } = await import('picomatch'); |
| 2774 | // `windows: false`: the stored paths always use `/`, so the glob reads the |
| 2775 | // same on every platform (picomatch otherwise follows the host OS). |
| 2776 | const options = { dot: true, windows: false }; |
| 2777 | let glob = pattern.trim(); |
| 2778 | if (glob.endsWith('/')) glob += '**'; |
| 2779 | if (!glob.includes('/')) { |
| 2780 | const matchName = picomatch(glob, options); |
| 2781 | return (filePath) => matchName(path.posix.basename(filePath)); |
| 2782 | } |
| 2783 | const anchored = /^\.?\//.test(glob); |
| 2784 | glob = glob.replace(/^\.?\/+/, ''); |
| 2785 | if (!anchored && !glob.startsWith('**/')) glob = `**/${glob}`; |
| 2786 | return picomatch(glob, options); |
| 2787 | } |
| 2788 | |
| 2789 | /** |
| 2790 | * codegraph implementations <symbol> |