-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
refactor(lib/run): simplify code to determine install/run target #1082
Conversation
When on this PR, it doesn't appear that the CLI properly detects of the emulator is already running and fails to redeploy the app on the
Prompt waits for the emulator to start when it's already running. |
Thanks for the thorough check @breautek. I'll look into this when I find the time. I converted this to a draft until then. |
If the `lookHarder` option is true and the initial `adb devices` run returned no devices, `device.list` will kill the adb server and try again. Unfortunately `adb devices` contains incorrect information when it is run too soon after the adb server has been restarted. Consider below commands being executed with one running emulator: adb devices && killall adb && adb devices && adb devices While the first invocation of `adb devices` lists the emulator as running, the second and third one will list it as offline. This is especially problematic if code contains a sequence such as: devs = await device.list(true); emus = await emulator.list(); In that case the third invocation of `adb devices` occurs in `emulator.list()` but because of the `killall` it lists all emulators as offline, causing `emus` to be empty. This commit tries to work around that issue by explicitly restarting the adb server after it was killed, and waiting for 100 ms after that. Local experimentation has shown this to be sufficient in all instances. YMMV of course.
01cca69
to
dd6ffd9
Compare
Codecov Report
@@ Coverage Diff @@
## master #1082 +/- ##
==========================================
- Coverage 69.83% 69.69% -0.15%
==========================================
Files 20 20
Lines 1810 1808 -2
==========================================
- Hits 1264 1260 -4
- Misses 546 548 +2
Continue to review full report at Codecov.
|
Closing in favor of #1101 |
Motivation and Context
This change simplifies the code that determines on which target (device or emulator) the app should be installed and run on.
This refactoring was triggered during a bigger refactoring (still WIP) that has the goal of doing something similar to apache/cordova-electron#142 here.
Description
The changes made here should not change the observable behavior of the code beyond changing what is logged to the console. The changes included are:
resolveInstallTarget
fromlib/run.run
lib/run
moduleresolveInstallTarget
to async/awaitresolveInstallTarget
The logic for selecting a install/run target is unchanged. Targets are tried to resolve in this order:
--emulator
option was not given)--device
option was not given)Testing
The unit tests for this module still pass.