MCPcopy
hub / github.com/foambubble/foam / findFilesRecursive

Function findFilesRecursive

packages/foam-vscode/src/test/vscode-mock.ts:1911–1941  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

1909 }
1910
1911 const findFilesRecursive = async (dir: string): Promise<string[]> => {
1912 const files: string[] = [];
1913 try {
1914 const entries = await fs.promises.readdir(dir, { withFileTypes: true });
1915
1916 for (const entry of entries) {
1917 const fullPath = path.join(dir, entry.name);
1918 const relativePath = path
1919 .relative(workspaceFolder.uri.fsPath, fullPath)
1920 .split(path.sep)
1921 .join('/');
1922
1923 if (entry.isDirectory()) {
1924 const subFiles = await findFilesRecursive(fullPath);
1925 files.push(...subFiles);
1926 } else if (entry.isFile()) {
1927 // Check if file matches include pattern
1928 if (micromatch.isMatch(relativePath, include)) {
1929 // Check if file matches exclude pattern
1930 if (!exclude || !micromatch.isMatch(relativePath, exclude)) {
1931 files.push(fullPath);
1932 }
1933 }
1934 }
1935 }
1936 } catch (error) {
1937 // Ignore errors accessing directories
1938 }
1939
1940 return files;
1941 };
1942
1943 try {
1944 const files = await findFilesRecursive(workspaceFolder.uri.fsPath);

Callers 1

findFilesFunction · 0.85

Calls 2

pushMethod · 0.80
isMatchMethod · 0.65

Tested by

no test coverage detected