Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* eslint-disable unused-imports/no-unused-vars */ import fs from 'node:fs/promises' import path from 'node:path' import { findUp } from 'find-up' import { parse } from 'yaml' export interface MonorepoInfo { root: string packages: string[] } export async function detectMonorepo(): Promise<MonorepoInfo | null> { const workspaceFile = await findUp('pnpm-workspace.yaml') if (!workspaceFile) return null try { const content = await fs.readFile(workspaceFile, 'utf8') const { packages = [] } = await parse(content) return { root: path.dirname(workspaceFile), packages: Array.isArray(packages) ? packages : [packages], } } catch (error) { throw new Error('Failed to parse pnpm-workspace.yaml') } } |