MCPcopy Create free account
hub / github.com/vercel/vercel / findPythonFilesRecursive

Function findPythonFilesRecursive

packages/python/src/entrypoint.ts:167–188  ·  view source on GitHub ↗

* Recursively walk workPath collecting .py files, skipping hidden dirs, * __pycache__, and node_modules. Only used on error paths.

(
  dir: string,
  rootDir: string
)

Source from the content-addressed store, hash-verified

165 * __pycache__, and node_modules. Only used on error paths.
166 */
167async function findPythonFilesRecursive(
168 dir: string,
169 rootDir: string
170): Promise<string[]> {
171 const results: string[] = [];
172 let entries;
173 try {
174 entries = await fs.promises.readdir(dir, { withFileTypes: true });
175 } catch {
176 return results;
177 }
178 for (const entry of entries) {
179 if (entry.name.startsWith('.') || SKIP_DIRS.has(entry.name)) continue;
180 const fullPath = join(dir, entry.name);
181 if (entry.isDirectory()) {
182 results.push(...(await findPythonFilesRecursive(fullPath, rootDir)));
183 } else if (entry.isFile() && entry.name.endsWith('.py')) {
184 results.push(relative(rootDir, fullPath).replace(/\\/g, '/'));
185 }
186 }
187 return results;
188}
189
190/**
191 * Recursive scan returning every .py file that exports a valid app/handler.

Callers 1

findEntrypointCandidatesFunction · 0.85

Calls 6

relativeFunction · 0.90
replaceMethod · 0.80
pushMethod · 0.65
hasMethod · 0.45
isDirectoryMethod · 0.45
isFileMethod · 0.45

Tested by

no test coverage detected