Skip to content

Commit

Permalink
fix(cli): test getConfig provider array fix
Browse files Browse the repository at this point in the history
Related #8467
  • Loading branch information
Jolg42 committed Aug 2, 2021
1 parent 9236d0e commit 677d34d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/packages/cli/src/bin.ts
Expand Up @@ -189,14 +189,26 @@ async function main(): Promise<number> {
let schemaProvider: string | undefined
let schemaPreviewFeatures: string[] | undefined
let schemaGeneratorsProviders: string[] | undefined

try {
const schema = await getSchema(args['--schema'])
const config = await getConfig({
datamodel: schema,
})

// There is a datasource let's see if it has a provider
if (config.datasources.length > 0) {
schemaProvider = config.datasources[0].provider
if (
Array.isArray(config.datasources[0].provider) &&
config.datasources[0].provider[0]
) {
// It shouldn't be an array but it is. See https://github.com/prisma/prisma/issues/8467
schemaProvider = config.datasources[0].provider[0]
} else {
schemaProvider = config.datasources[0].provider
}
}

const generator = config.generators.find(
(gen) => gen.previewFeatures.length > 0,
)
Expand Down

0 comments on commit 677d34d

Please sign in to comment.