MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getDeviceChoice

Function getDeviceChoice

npm_modules/cli/src/utils/buildInfo.ts:27–50  ·  view source on GitHub ↗
(platform: string)

Source from the content-addressed store, hash-verified

25// Prompts User to choose from the list of available devices
26// No prompt if only one device is available
27async function getDeviceChoice(platform: string): Promise<string> {
28 const availableDevices = await getConnectedDevices(platform);
29
30 if (availableDevices.length === 0) {
31 throw new CliError('No devices connected...');
32 } else if (availableDevices.length === 1) {
33 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
34 const selectedDevice: string = availableDevices[0]!;
35 console.log('Only one device connected, using it:', wrapInColor(selectedDevice, ANSI_COLORS.GREEN_COLOR));
36 return selectedDevice;
37 }
38
39 // Prompt user to select a device
40 const choices: Array<CliChoice<string> | Separator> = [];
41
42 if (platform === PLATFORM.ANDROID) {
43 choices.push(new Separator('-----Android Devices-----'));
44 } else if (platform === PLATFORM.IOS) {
45 choices.push(new Separator('-----iOS Devices-----'));
46 }
47 choices.push(...availableDevices.map(device => ({ name: device, value: device })));
48
49 return await getUserChoice(choices, 'Please select a device to perform the install:');
50}
51
52export async function getBuildInfo(argv: ArgumentsResolver<CommandParameters>, bazel: BazelClient, checkDevice: boolean): Promise<BuildInfo> {
53 const platform = argv.getArgument('platform') as PLATFORM;

Callers 1

getBuildInfoFunction · 0.85

Calls 6

getConnectedDevicesFunction · 0.90
wrapInColorFunction · 0.90
getUserChoiceFunction · 0.90
logMethod · 0.65
pushMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected