MCPcopy
hub / github.com/prisma/prisma / getGenerationDirs

Function getGenerationDirs

packages/client-generator-js/src/generateClient.ts:525–555  ·  view source on GitHub ↗

* Get all the directories involved in the generation process. * * @returns

({
  runtimeBase,
  generator,
  outputDir,
  datamodel,
  schemaPath,
  testMode,
}: GenerateClientOptions)

Source from the content-addressed store, hash-verified

523 * @returns
524 */
525async function getGenerationDirs({
526 runtimeBase,
527 generator,
528 outputDir,
529 datamodel,
530 schemaPath,
531 testMode,
532}: GenerateClientOptions) {
533 const isCustomOutput = generator.isCustomOutput === true
534 const normalizedOutputDir = path.normalize(outputDir)
535 let userRuntimeImport = isCustomOutput ? './runtime' : '@prisma/client/runtime'
536 let userOutputDir = isCustomOutput ? normalizedOutputDir : getDefaultOutdir(normalizedOutputDir)
537
538 if (testMode && runtimeBase) {
539 userOutputDir = outputDir
540 userRuntimeImport = pathToPosix(runtimeBase)
541 }
542
543 if (isCustomOutput) {
544 await verifyOutputDirectory(userOutputDir, datamodel, schemaPath)
545 }
546
547 const userPackageRoot = await packageUp({ cwd: path.dirname(userOutputDir) })
548 const userProjectRoot = userPackageRoot ? path.dirname(userPackageRoot) : process.cwd()
549
550 return {
551 runtimeBase: userRuntimeImport,
552 outputDir: userOutputDir,
553 projectRoot: userProjectRoot,
554 }
555}
556
557async function verifyOutputDirectory(directory: string, datamodel: string, schemaPath: string) {
558 let content: string

Callers 1

generateClientFunction · 0.70

Calls 3

pathToPosixFunction · 0.90
getDefaultOutdirFunction · 0.85
verifyOutputDirectoryFunction · 0.85

Tested by

no test coverage detected