MCPcopy Create free account
hub / github.com/github/gh-aw / getDirectLocalRequires

Function getDirectLocalRequires

actions/setup/js/setup_sh_file_lists.test.cjs:29–38  ·  view source on GitHub ↗

* Return all local ./relative requires from a .cjs file (non-recursive). * Only captures static string literals, ignores dynamic requires.

(filename)

Source from the content-addressed store, hash-verified

27 * Only captures static string literals, ignores dynamic requires.
28 */
29function 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.

Callers 1

collectTransitiveDepsFunction · 0.85

Calls 1

readFileSyncFunction · 0.85

Tested by

no test coverage detected