| 2918 | // `tests/x.py` (`**` matches zero folders). Dotfiles count. picomatch is |
| 2919 | // loaded here, not at startup, since only this command needs it. |
| 2920 | async function affectedFilterMatcher(pattern: string): Promise<(filePath: string) => boolean> { |
| 2921 | const { default: picomatch } = await import('picomatch'); |
| 2922 | // `windows: false`: the stored paths always use `/`, so the glob reads the |
| 2923 | // same on every platform (picomatch otherwise follows the host OS). |
| 2924 | const options = { dot: true, windows: false }; |
| 2925 | let glob = pattern.trim(); |
| 2926 | if (glob.endsWith('/')) glob += '**'; |
| 2927 | if (!glob.includes('/')) { |
| 2928 | const matchName = picomatch(glob, options); |
| 2929 | return (filePath) => matchName(path.posix.basename(filePath)); |
| 2930 | } |
| 2931 | const anchored = /^\.?\//.test(glob); |
| 2932 | glob = glob.replace(/^\.?\/+/, ''); |
| 2933 | if (!anchored && !glob.startsWith('**/')) glob = `**/${glob}`; |
| 2934 | return picomatch(glob, options); |
| 2935 | } |
| 2936 | |
| 2937 | /** |
| 2938 | * codegraph implementations <symbol> |