MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / expandWorkspaceGlob

Function expandWorkspaceGlob

src/resolution/workspace-packages.ts:295–314  ·  view source on GitHub ↗

Expand one level of a `packages/*` / `apps/**` glob to member dirs.

(projectRoot: string, pattern: string)

Source from the content-addressed store, hash-verified

293
294/** Expand one level of a `packages/*` / `apps/**` glob to member dirs. */
295function expandWorkspaceGlob(projectRoot: string, pattern: string): string[] {
296 const norm = pattern.replace(/\\/g, '/').replace(/\/+$/, '');
297 const star = norm.indexOf('*');
298 if (star === -1) return [norm]; // exact directory
299
300 // Everything before the wildcard segment is the base to enumerate.
301 const base = norm.slice(0, star).replace(/\/+$/, '');
302 let entries: fs.Dirent[];
303 try {
304 entries = fs.readdirSync(path.join(projectRoot, base), { withFileTypes: true });
305 } catch {
306 return [];
307 }
308 const out: string[] = [];
309 for (const e of entries) {
310 if (!e.isDirectory() || e.name.startsWith('.') || e.name === 'node_modules') continue;
311 out.push(base ? `${base}/${e.name}` : e.name);
312 }
313 return out;
314}
315
316/** Read the `name` field from a member directory's package.json. */
317function readPackageName(dirAbs: string): string | null {

Callers 1

loadWorkspacePackagesFunction · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected