MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / affectedFilterMatcher

Function affectedFilterMatcher

src/bin/codegraph.ts:2927–2942  ·  view source on GitHub ↗
(pattern: string)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected