-
Notifications
You must be signed in to change notification settings - Fork 905
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
Feat: List android devices #1765
Feat: List android devices #1765
Conversation
packages/cli-platform-android/src/commands/runAndroid/listAndroidDevices.ts
Outdated
Show resolved
Hide resolved
…oidDevices.ts Co-authored-by: Szymon Rybczak <szymon.rybczak@gmail.com>
|
||
const device = await listAndroidDevices(); | ||
if (!device) { | ||
return logger.error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will exit with code 0. I think we want to throw?
} else { | ||
logger.error( | ||
`Failed to launch emulator. Reason: ${chalk.dim(result.error || '')}.`, | ||
); | ||
logger.warn( | ||
'Please launch an emulator manually or connect a device. Otherwise app may fail to launch.', | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw so the exit code is non-zero
packages/cli-platform-android/src/commands/runAndroid/listAndroidDevices.ts
Outdated
Show resolved
Hide resolved
packages/cli-platform-android/src/commands/runAndroid/listAndroidDevices.ts
Show resolved
Hide resolved
return buffer | ||
.toString() | ||
.replace(/\[ro\.product\.model\]:\s*\[(.*)\]/, '$1') | ||
.trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please extract transforming regex to a separate fn and write unit tests :)
|
||
const emulatorCommand = process.env.ANDROID_HOME | ||
? `${process.env.ANDROID_HOME}/emulator/emulator` | ||
: 'emulator'; | ||
|
||
const getEmulators = () => { | ||
export const getEmulators = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider moving it to separate file to avoid unexpected circular deps and make it clearer what's shared (although one could say export
says it all, and they would be right)
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this merged 👍🏼
Summary:
Similar to #1676 - list available devices and let user choose from one.
Fetch available devices (
adb device
) and emulators (emulator -list-avds
) and pass selection torun-android
command.If user select either physical device or booted emulator we simply call
runOnSpecificDevice
with selected deviceId.Gets a bit trickier when user selects not-booted emulator. We need to launch it at known port bc we need it to pass all further avd commands (
avd -s emulator-${port} [command]
).Test Plan:
Clone the fork and run
run-android
script with proper flag: