(cwd: string)
| 43 | } |
| 44 | |
| 45 | export async function hasWorkspacesEnabled(cwd: string): Promise<boolean> { |
| 46 | const packageJson = await readRootPackageJson(cwd); |
| 47 | if (!packageJson.private) { |
| 48 | return false; |
| 49 | } |
| 50 | if (Array.isArray(packageJson.workspaces)) { |
| 51 | return packageJson.workspaces.length > 0; |
| 52 | } |
| 53 | if (typeof packageJson.workspaces === 'object') { |
| 54 | return Boolean(packageJson.workspaces.packages?.length); |
| 55 | } |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | export async function readRootPackageJson(cwd: string): Promise<PackageJson> { |
| 60 | return await readJsonFile<PackageJson>(path.join(cwd, 'package.json')); |
no test coverage detected