diff --git a/packages/eas-cli/src/build/graphql.ts b/packages/eas-cli/src/build/graphql.ts index c30b1cd71c..1de6922a65 100644 --- a/packages/eas-cli/src/build/graphql.ts +++ b/packages/eas-cli/src/build/graphql.ts @@ -6,6 +6,7 @@ import { Metadata, Workflow, } from '@expo/eas-build-job'; +import assert from 'assert'; import { BuildCredentialsSource, @@ -91,16 +92,16 @@ export function transformIosEnterpriseProvisioning( } } +const buildModeToGraphQLBuildMode: Record = { + [BuildMode.BUILD]: GraphQLBuildMode.Build, + [BuildMode.CUSTOM]: GraphQLBuildMode.Custom, + [BuildMode.RESIGN]: GraphQLBuildMode.Resign, +}; + export function transformBuildMode(buildMode: BuildMode): GraphQLBuildMode { - if (buildMode === 'build') { - return GraphQLBuildMode.Build; - } else if (buildMode === 'resign') { - return GraphQLBuildMode.Resign; - } else if (buildMode === 'custom') { - return GraphQLBuildMode.Custom; - } else { - throw new Error(`Unsupported build mode: ${buildMode}`); - } + const graphQLBuildMode = buildModeToGraphQLBuildMode[buildMode]; + assert(graphQLBuildMode, `Unsupported build mode: ${buildMode}`); + return graphQLBuildMode; } export function transformBuildTrigger(buildTrigger: BuildTrigger): GraphQLBuildTrigger {