(platformName: string)
| 24 | } |
| 25 | |
| 26 | export async function getPlatformTargets(platformName: string): Promise<PlatformTarget[]> { |
| 27 | const errors = []; |
| 28 | try { |
| 29 | const output = await runNativeRun([platformName, '--list', '--json']); |
| 30 | const parsedOutput = JSON.parse(output); |
| 31 | if (parsedOutput.devices.length || parsedOutput.virtualDevices.length) { |
| 32 | return [ |
| 33 | ...parsedOutput.devices.map((t: any) => ({ ...t, virtual: false })), |
| 34 | ...parsedOutput.virtualDevices.map((t: any) => ({ |
| 35 | ...t, |
| 36 | virtual: true, |
| 37 | })), |
| 38 | ]; |
| 39 | } else { |
| 40 | parsedOutput.errors.map((e: any) => { |
| 41 | errors.push(e); |
| 42 | }); |
| 43 | } |
| 44 | } catch (e: any) { |
| 45 | const err = JSON.parse(e); |
| 46 | errors.push(err); |
| 47 | } |
| 48 | |
| 49 | if (errors.length === 0) { |
| 50 | logger.info('No devices found.'); |
| 51 | return []; |
| 52 | } |
| 53 | |
| 54 | const plural = errors.length > 1 ? 's' : ''; |
| 55 | const errMsg = `${c.strong('native-run')} failed with error${plural}\n |
| 56 | ${errors |
| 57 | .map((e: any) => { |
| 58 | return `\t${c.strong(e.code)}: ${e.error}`; |
| 59 | }) |
| 60 | .join('\n')} |
| 61 | \n\tMore details for this error${plural} may be available online: ${c.strong( |
| 62 | 'https://github.com/ionic-team/native-run/wiki/Android-Errors', |
| 63 | )} |
| 64 | `; |
| 65 | throw errMsg; |
| 66 | } |
no test coverage detected