( cwd: string, patterns: string[] = ['**'], )
| 11 | }; |
| 12 | |
| 13 | export async function listPackages( |
| 14 | cwd: string, |
| 15 | patterns: string[] = ['**'], |
| 16 | ): Promise<WorkspacePackage[]> { |
| 17 | const files = await glob( |
| 18 | patterns.map(pattern => pattern.replace(/\/?$/, '/package.json')), |
| 19 | { cwd }, |
| 20 | ); |
| 21 | |
| 22 | return Promise.all( |
| 23 | files.toSorted().map(async (file): Promise<WorkspacePackage> => { |
| 24 | const packageJson = await readJsonFile<PackageJson>(path.join(cwd, file)); |
| 25 | const directory = path.join(cwd, path.dirname(file)); |
| 26 | const name = packageJson.name || path.basename(directory); |
| 27 | return { name, directory, packageJson }; |
| 28 | }), |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | export async function listWorkspaces( |
| 33 | cwd: string, |
no outgoing calls
no test coverage detected