MCPcopy Create free account
hub / github.com/cloudflare/agents / extractFilePaths

Function extractFilePaths

scripts/check-exports.ts:9–28  ·  view source on GitHub ↗

* Recursively extract all file paths from an exports object

(
  exports: unknown,
  paths: Set<string> = new Set()
)

Source from the content-addressed store, hash-verified

7 * Recursively extract all file paths from an exports object
8 */
9function extractFilePaths(
10 exports: unknown,
11 paths: Set<string> = new Set()
12): Set<string> {
13 if (typeof exports === "string") {
14 // Simple string path
15 paths.add(exports);
16 } else if (Array.isArray(exports)) {
17 // Array of paths
18 for (const item of exports) {
19 extractFilePaths(item, paths);
20 }
21 } else if (exports && typeof exports === "object") {
22 // Object with conditions (import, require, types, default, etc.)
23 for (const value of Object.values(exports)) {
24 extractFilePaths(value, paths);
25 }
26 }
27 return paths;
28}
29
30/**
31 * Check if all files referenced in a package's exports field exist

Callers 1

checkPackageFunction · 0.85

Calls 2

valuesMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected