(generator: GeneratorConfig)
| 167 | } |
| 168 | |
| 169 | async 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 | |
| 195 | function formatErrors(errors: GetConfigValidationError[]) { |
| 196 | const formattedErrors = errors.map((e) => relativizePathInPSLError(e.message)).join('\n\n') |
no test coverage detected