| 2865 | // `tests/x.py` (`**` matches zero folders). Dotfiles count. picomatch is |
| 2866 | // loaded here, not at startup, since only this command needs it. |
| 2867 | async function affectedFilterMatcher(pattern: string): Promise<(filePath: string) => boolean> { |
| 2868 | const { default: picomatch } = await import('picomatch'); |
| 2869 | // `windows: false`: the stored paths always use `/`, so the glob reads the |
| 2870 | // same on every platform (picomatch otherwise follows the host OS). |
| 2871 | const options = { dot: true, windows: false }; |
| 2872 | let glob = pattern.trim(); |
| 2873 | if (glob.endsWith('/')) glob += '**'; |
| 2874 | if (!glob.includes('/')) { |
| 2875 | const matchName = picomatch(glob, options); |
| 2876 | return (filePath) => matchName(path.posix.basename(filePath)); |
| 2877 | } |
| 2878 | const anchored = /^\.?\//.test(glob); |
| 2879 | glob = glob.replace(/^\.?\/+/, ''); |
| 2880 | if (!anchored && !glob.startsWith('**/')) glob = `**/${glob}`; |
| 2881 | return picomatch(glob, options); |
| 2882 | } |
| 2883 | |
| 2884 | /** |
| 2885 | * codegraph implementations <symbol> |