MCPcopy Index your code
hub / github.com/coder/coder / collectFiles

Function collectFiles

site/scripts/check-compiler.mjs:49–74  ·  view source on GitHub ↗

* Recursively collect .ts/.tsx files under `dir`, skipping test and * story files. Returns paths relative to `siteDir`. Sets * `hadCollectionErrors` and returns an empty array on ENOENT so the * caller and recursive calls both stay safe.

(dir)

Source from the content-addressed store, hash-verified

47 * caller and recursive calls both stay safe.
48 */
49function collectFiles(dir) {
50 let entries;
51 try {
52 entries = readdirSync(dir, { withFileTypes: true });
53 } catch (e) {
54 if (e.code === "ENOENT") {
55 console.error(`Target directory not found: ${relative(siteDir, dir)}`);
56 hadCollectionErrors = true;
57 return [];
58 }
59 throw e;
60 }
61 const results = [];
62 for (const entry of entries) {
63 const full = join(dir, entry.name);
64 if (entry.isDirectory()) {
65 results.push(...collectFiles(full));
66 } else if (
67 (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")) &&
68 !skipPatterns.some((p) => entry.name.includes(p))
69 ) {
70 results.push(relative(siteDir, full));
71 }
72 }
73 return results;
74}
75
76// ---------------------------------------------------------------------------
77// Compilation & diagnostics

Callers 1

check-compiler.mjsFile · 0.85

Calls 2

relativeFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected