Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Better native-run error #4676

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}