MCPcopy
hub / github.com/prisma/prisma / getCurrentClientVersion

Function getCurrentClientVersion

packages/cli/src/Generate.ts:347–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

345}
346
347function 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}

Callers 1

parseMethod · 0.85

Calls 1

resolvePkgFunction · 0.85

Tested by

no test coverage detected