* Get all the directories involved in the generation process. * * @returns
({
runtimeBase,
generator,
outputDir,
datamodel,
schemaPath,
testMode,
}: GenerateClientOptions)
| 523 | * @returns |
| 524 | */ |
| 525 | async 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 | |
| 557 | async function verifyOutputDirectory(directory: string, datamodel: string, schemaPath: string) { |
| 558 | let content: string |
no test coverage detected