MCPcopy Create free account
hub / github.com/backnotprop/plannotator / hasMarkdownFiles

Function hasMarkdownFiles

packages/shared/resolve-file.ts:486–509  ·  view source on GitHub ↗
(
	dirPath: string,
	excludedDirs: string[] = IGNORED_DIRS,
	extensions: RegExp = /\.mdx?$/i,
)

Source from the content-addressed store, hash-verified

484 * @param extensions - Regex to match file extensions (default: markdown only)
485 */
486export function hasMarkdownFiles(
487 dirPath: string,
488 excludedDirs: string[] = IGNORED_DIRS,
489 extensions: RegExp = /\.mdx?$/i,
490): boolean {
491 function walk(dir: string): boolean {
492 let entries;
493 try {
494 entries = readdirSync(dir, { withFileTypes: true });
495 } catch {
496 return false;
497 }
498 for (const entry of entries) {
499 if (entry.isDirectory()) {
500 if (excludedDirs.some((d) => d === entry.name + "/")) continue;
501 if (walk(join(dir, entry.name))) return true;
502 } else if (entry.isFile() && extensions.test(entry.name)) {
503 return true;
504 }
505 }
506 return false;
507 }
508 return walk(dirPath);
509}

Callers 3

handleAnnotateCommandFunction · 0.90
index.tsFile · 0.90
plannotatorFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected