* Return all local ./relative requires from a .cjs file (non-recursive). * Only captures static string literals, ignores dynamic requires.
(filename)
| 27 | * Only captures static string literals, ignores dynamic requires. |
| 28 | */ |
| 29 | function getDirectLocalRequires(filename) { |
| 30 | const filePath = resolve(__dirname, filename); |
| 31 | if (!existsSync(filePath)) return []; |
| 32 | const content = readFileSync(filePath, "utf8"); |
| 33 | const deps = []; |
| 34 | for (const match of content.matchAll(/require\(["']\.\/([\w\-./]+\.cjs)["']\)/g)) { |
| 35 | deps.push(match[1]); |
| 36 | } |
| 37 | return deps; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Collect all transitive local dependencies starting from the given root files. |
no test coverage detected