(cwd: string, patterns: string[])
| 500 | } |
| 501 | |
| 502 | function findNextjsInWorkspace(cwd: string, patterns: string[]): string | null { |
| 503 | const packagePaths = expandWorkspacePatterns(cwd, patterns) |
| 504 | const versions: string[] = [] |
| 505 | |
| 506 | for (const pkgPath of packagePaths) { |
| 507 | try { |
| 508 | const nextPkgPath = require.resolve('next/package.json', { |
| 509 | paths: [pkgPath], |
| 510 | }) |
| 511 | const pkg = JSON.parse(fs.readFileSync(nextPkgPath, 'utf-8')) |
| 512 | if (pkg.version) { |
| 513 | versions.push(pkg.version) |
| 514 | } |
| 515 | } catch { |
| 516 | // Next.js not installed in this package |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | return findHighestVersion(versions) |
| 521 | } |
| 522 | |
| 523 | function expandWorkspacePatterns(cwd: string, patterns: string[]): string[] { |
| 524 | const packagePaths: string[] = [] |
no test coverage detected