Expand one level of a `packages/*` / `apps/**` glob to member dirs.
(projectRoot: string, pattern: string)
| 293 | |
| 294 | /** Expand one level of a `packages/*` / `apps/**` glob to member dirs. */ |
| 295 | function 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. */ |
| 317 | function readPackageName(dirAbs: string): string | null { |
no test coverage detected