fix: ignore log lines in avd_list, fix docs.rs build (#414)

This commit is contained in:
Amr Bashir
2024-10-23 16:10:44 +03:00
committed by GitHub
parent 310e23c88a
commit c4d420f9b9
3 changed files with 24 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"cargo-mobile2": "patch"
---
Fix `android::emulator::avd_list` function interpreting log lines from `emulator -list-avd` as valid `Emulator`

View File

@@ -15,6 +15,17 @@ keywords = [ "cargo", "mobile", "ios", "android", "tauri" ]
categories = [ "development-tools::cargo-plugins" ]
license = "Apache-2.0 OR MIT"
[package.metadata.docs.rs]
no-default-features = true
features = ["native-tls"]
default-target = "x86_64-unknown-linux-gnu"
targets = [
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin",
]
[[bin]]
name = "cargo-mobile"
required-features = [ "cli" ]
@@ -42,7 +53,7 @@ cli = [
brainium = [ ]
rustls = [ "ureq/tls" ]
native-tls = [ "ureq/native-tls" ]
default = [ "cli", "ureq/native-tls" ]
default = [ "cli", "native-tls" ]
[dependencies]
handlebars = "6.0"

View File

@@ -21,7 +21,7 @@ pub fn avd_list(env: &Env) -> Result<BTreeSet<Emulator>, Error> {
raw_list
.split('\n')
.filter_map(|name| {
if name.is_empty() {
if name.is_empty() || is_emulator_log_line(name) {
None
} else {
Some(Emulator::new(name.trim().into()))
@@ -31,3 +31,9 @@ pub fn avd_list(env: &Env) -> Result<BTreeSet<Emulator>, Error> {
})
.map_err(Error::ListAvdsFailed)
}
fn is_emulator_log_line(name: &str) -> bool {
["INFO |", "WARNING |", "ERROR |"]
.iter()
.any(|prefix| name.starts_with(prefix))
}