* 递归查找匹配的文件
(dir, pattern, results = [], depth = 0, maxDepth = 10)
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * 向上查找 monorepo 根目录(包含 pnpm-workspace.yaml 或根 node_modules) |
| 39 | */ |
| 40 | function findMonorepoRoot(startDir) { |
| 41 | let dir = startDir; |
| 42 | while (dir !== dirname(dir)) { |
| 43 | // 检查是否存在 pnpm-workspace.yaml(pnpm monorepo 标志) |
| 44 | if (existsSync(join(dir, 'pnpm-workspace.yaml'))) { |
| 45 | return dir; |
| 46 | } |
| 47 | // 检查是否存在 node_modules/.pnpm(pnpm 的依赖目录) |
| 48 | if (existsSync(join(dir, 'node_modules', '.pnpm'))) { |
| 49 | return dir; |
| 50 | } |
| 51 | dir = dirname(dir); |
| 52 | } |
| 53 | return null; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * 递归查找匹配的文件 |
| 58 | */ |
| 59 | function findFiles(dir, pattern, results = [], depth = 0, maxDepth = 10) { |
| 60 | if (depth > maxDepth) return results; |
| 61 |
no test coverage detected