Skip to content

Commit

Permalink
fix(sdk,client): introduce isCustomOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Apr 28, 2020
1 parent a68deff commit 2809a74
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/packages/client/src/generation/generateClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,16 @@ export async function generateClient({
clientVersion,
engineVersion,
}: GenerateClientOptions): Promise<BuildClientResult | undefined> {
const isInNodeModules = outputDir.includes(
`${path.sep}node_modules${path.sep}`,
)
runtimePath =
runtimePath || (isInNodeModules ? '@prisma/client/runtime' : './runtime')
runtimePath ||
(generator?.isCustomOutput ? './runtime' : '@prisma/client/runtime')

debug(`outputDir: ${outputDir}`)
const dotPrismaDir = path.join(outputDir, '../../.prisma/client')

// Cheap check, if people use custom dir
const finalOutputDir = isInNodeModules || testMode ? dotPrismaDir : outputDir
const finalOutputDir =
!generator?.isCustomOutput || testMode ? dotPrismaDir : outputDir

const { prismaClientDmmf, fileMap } = await buildClient({
datamodel,
Expand Down
1 change: 1 addition & 0 deletions src/packages/generator-helper/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export type Dictionary<T> = { [key: string]: T }
export interface GeneratorConfig {
name: string
output: string | null
isCustomOutput?: boolean
provider: string
config: Dictionary<string>
binaryTargets: string[] // check if new commit is there
Expand Down
1 change: 1 addition & 0 deletions src/packages/sdk/src/getGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export async function getGenerators({
// resolve output path
if (generator.output) {
generator.output = path.resolve(baseDir, generator.output)
generator.isCustomOutput = true
debug(`Resolving based on generator.output to ${generator.output}`)
} else if (paths) {
generator.output = paths.outputPath
Expand Down

0 comments on commit 2809a74

Please sign in to comment.