Skip to content

Commit

Permalink
[eas-cli] Add getters
Browse files Browse the repository at this point in the history
Added getters for requested platform from string flag value

See: https://linear.app/expo/issue/ENG-9175/update-oclif-in-eas-cli
  • Loading branch information
radoslawkrzemien committed Dec 1, 2023
1 parent bdfcd6c commit 74f6f06
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/eas-cli/src/platform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Platform } from '@expo/eas-build-job';
import { Errors } from '@oclif/core';

import { AppPlatform } from './graphql/generated';
import { promptAsync } from './prompts';
Expand All @@ -20,6 +21,27 @@ export enum RequestedPlatform {
All = 'all',
}

export function maybeGetRequestedPlatform(
requestedPlatformString: string | undefined
): RequestedPlatform | undefined {
if (!requestedPlatformString) {
return undefined;
}
return Object.values(RequestedPlatform).find(
requestedPlatform => requestedPlatform === requestedPlatformString
);
}

export function getRequestedPlatform(requestedPlatformString: string): RequestedPlatform {
const parsedRequestedPlatform = Object.values(RequestedPlatform).find(
requestedPlatform => requestedPlatform === requestedPlatformString
);
if (!parsedRequestedPlatform) {
Errors.error(`"${requestedPlatformString}" RequestedPlatform does not exist`, { exit: 1 });
}
return parsedRequestedPlatform;
}

export const requestedPlatformDisplayNames: Record<RequestedPlatform, string> = {
[RequestedPlatform.Android]: 'Android',
[RequestedPlatform.Ios]: 'iOS',
Expand Down

0 comments on commit 74f6f06

Please sign in to comment.