MCPcopy
hub / github.com/prisma/prisma / resolveBinaryTargets

Function resolveBinaryTargets

packages/internals/src/engine-commands/getConfig.ts:169–193  ·  view source on GitHub ↗
(generator: GeneratorConfig)

Source from the content-addressed store, hash-verified

167}
168
169async function resolveBinaryTargets(generator: GeneratorConfig) {
170 for (const binaryTarget of generator.binaryTargets) {
171 // load the binaryTargets from the env var
172 if (binaryTarget.fromEnvVar && process.env[binaryTarget.fromEnvVar]) {
173 const value = JSON.parse(process.env[binaryTarget.fromEnvVar]!)
174
175 if (Array.isArray(value)) {
176 generator.binaryTargets = value.map((v) => ({ fromEnvVar: null, value: v }))
177 await resolveBinaryTargets(generator) // resolve again if we have native
178 } else {
179 binaryTarget.value = value
180 }
181 }
182
183 // resolve native to the current platform
184 if (binaryTarget.value === 'native') {
185 binaryTarget.value = await getBinaryTargetForCurrentPlatform()
186 binaryTarget.native = true
187 }
188 }
189
190 if (generator.binaryTargets.length === 0) {
191 generator.binaryTargets = [{ fromEnvVar: null, value: await getBinaryTargetForCurrentPlatform(), native: true }]
192 }
193}
194
195function formatErrors(errors: GetConfigValidationError[]) {
196 const formattedErrors = errors.map((e) => relativizePathInPSLError(e.message)).join('\n\n')

Callers 1

getConfigFunction · 0.85

Calls 2

parseMethod · 0.65

Tested by

no test coverage detected