* Recursively extract all file paths from an exports object
( exports: unknown, paths: Set<string> = new Set() )
| 7 | * Recursively extract all file paths from an exports object |
| 8 | */ |
| 9 | function 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 |
no test coverage detected