| 345 | } |
| 346 | |
| 347 | function getCurrentClientVersion(): string | null { |
| 348 | try { |
| 349 | let pkgPath = resolvePkg('.prisma/client', { cwd: process.cwd() }) |
| 350 | if (!pkgPath) { |
| 351 | const potentialPkgPath = path.join(process.cwd(), 'node_modules/.prisma/client') |
| 352 | if (fs.existsSync(potentialPkgPath)) { |
| 353 | pkgPath = potentialPkgPath |
| 354 | } |
| 355 | } |
| 356 | if (pkgPath) { |
| 357 | const indexPath = path.join(pkgPath, 'index.js') |
| 358 | if (fs.existsSync(indexPath)) { |
| 359 | const program = require(indexPath) |
| 360 | return program?.prismaVersion?.client ?? program?.Prisma?.prismaVersion?.client |
| 361 | } |
| 362 | } |
| 363 | } catch (e) { |
| 364 | return null |
| 365 | } |
| 366 | |
| 367 | return null |
| 368 | } |