From aae9babc8643f6973b0b0aecc7ca820846240ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Tue, 28 Nov 2023 15:34:37 +0100 Subject: [PATCH] Simplify (imo) --- packages/eas-cli/src/build/graphql.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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 {