Skip to content

Commit

Permalink
fix(cli): Better native-run error (#4676)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Jun 3, 2021
1 parent a13b628 commit 39eebd0
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions cli/src/util/native-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,24 @@ export async function runNativeRun(
export async function getPlatformTargets(
platformName: string,
): Promise<PlatformTarget[]> {
const output = await runNativeRun([platformName, '--list', '--json']);
const parsedOutput = JSON.parse(output);
try {
const output = await runNativeRun([platformName, '--list', '--json']);
const parsedOutput = JSON.parse(output);

return [
...parsedOutput.devices.map((t: any) => ({ ...t, virtual: false })),
...parsedOutput.virtualDevices.map((t: any) => ({ ...t, virtual: true })),
];
return [
...parsedOutput.devices.map((t: any) => ({ ...t, virtual: false })),
...parsedOutput.virtualDevices.map((t: any) => ({ ...t, virtual: true })),
];
} catch (e) {
const err = JSON.parse(e);
const errMsg = `${c.strong('native-run')} failed with error ${c.strong(
err.code,
)}: ${err.error}
\tMore details for this error may be available online: ${c.strong(
'https://github.com/ionic-team/native-run/wiki/Android-Errors',
)}
`;
throw errMsg;
}
}

0 comments on commit 39eebd0

Please sign in to comment.