fix(cli/mobile): strip \n before parsing json (#5126)

This commit is contained in:
Amr Bashir
2022-09-02 15:30:42 +02:00
committed by GitHub
parent aae91a9b53
commit 5643ece77c
2 changed files with 6 additions and 5 deletions

View File

@@ -62,7 +62,7 @@ pub fn init_dot_cargo(app: &App, android: Option<(&AndroidEnv, &AndroidConfig)>)
pub fn exec(
target: Target,
wrapper: &TextWrapper,
non_interactive: bool,
#[allow(unused_variables)] non_interactive: bool,
#[allow(unused_variables)] reinstall_deps: bool,
) -> Result<App> {
let tauri_config = get_tauri_config(None)?;

View File

@@ -184,10 +184,10 @@ fn read_options(config: &TauriConfig, target: Target) -> CliOptions {
let mut attempt = 0;
let max_tries = 5;
let buffer = loop {
let (buffer, len) = loop {
let mut buffer = String::new();
if conn.read_line(&mut buffer).is_ok() {
break buffer;
if let Ok(len) = conn.read_line(&mut buffer) {
break (buffer, len);
}
std::thread::sleep(std::time::Duration::from_secs(1));
attempt += 1;
@@ -199,7 +199,8 @@ fn read_options(config: &TauriConfig, target: Target) -> CliOptions {
std::process::exit(1);
}
};
let options: CliOptions = serde_json::from_str(&buffer).expect("invalid CLI options");
let options: CliOptions = serde_json::from_str(&buffer[..len - 1]).expect("invalid CLI options");
for (k, v) in &options.vars {
set_var(k, v);
}