mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
fix(cli): duplicated newlines on child process output (#8042)
This commit is contained in:
committed by
GitHub
parent
94bef1c705
commit
be8e5aa307
7
.changes/fix-cmd-output.md
Normal file
7
.changes/fix-cmd-output.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@tauri-apps/cli": patch:bug
|
||||
"tauri-cli": patch:bug
|
||||
"tauri-bundler": patch:bug
|
||||
---
|
||||
|
||||
Fixes duplicated newlines on command outputs.
|
||||
2
examples/api/src-tauri/Cargo.lock
generated
2
examples/api/src-tauri/Cargo.lock
generated
@@ -3529,7 +3529,7 @@ checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5"
|
||||
|
||||
[[package]]
|
||||
name = "tauri"
|
||||
version = "1.5.1"
|
||||
version = "1.5.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.21.2",
|
||||
|
||||
@@ -8,7 +8,7 @@ use log::debug;
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
fs::{self, File},
|
||||
io::{self, BufReader, BufWriter},
|
||||
io::{self, BufRead, BufReader, BufWriter},
|
||||
path::Path,
|
||||
process::{Command, ExitStatus, Output, Stdio},
|
||||
sync::{Arc, Mutex},
|
||||
@@ -165,16 +165,15 @@ impl CommandExt for Command {
|
||||
let stdout_lines = Arc::new(Mutex::new(Vec::new()));
|
||||
let stdout_lines_ = stdout_lines.clone();
|
||||
std::thread::spawn(move || {
|
||||
let mut buf = Vec::new();
|
||||
let mut line = String::new();
|
||||
let mut lines = stdout_lines_.lock().unwrap();
|
||||
loop {
|
||||
buf.clear();
|
||||
if let Ok(0) = tauri_utils::io::read_line(&mut stdout, &mut buf) {
|
||||
line.clear();
|
||||
if let Ok(0) = stdout.read_line(&mut line) {
|
||||
break;
|
||||
}
|
||||
debug!(action = "stdout"; "{}", String::from_utf8_lossy(&buf));
|
||||
lines.extend(buf.clone());
|
||||
lines.push(b'\n');
|
||||
debug!(action = "stdout"; "{}", &line[0..line.len() - 1]);
|
||||
lines.extend(line.as_bytes().to_vec());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -182,16 +181,15 @@ impl CommandExt for Command {
|
||||
let stderr_lines = Arc::new(Mutex::new(Vec::new()));
|
||||
let stderr_lines_ = stderr_lines.clone();
|
||||
std::thread::spawn(move || {
|
||||
let mut buf = Vec::new();
|
||||
let mut line = String::new();
|
||||
let mut lines = stderr_lines_.lock().unwrap();
|
||||
loop {
|
||||
buf.clear();
|
||||
if let Ok(0) = tauri_utils::io::read_line(&mut stderr, &mut buf) {
|
||||
line.clear();
|
||||
if let Ok(0) = stderr.read_line(&mut line) {
|
||||
break;
|
||||
}
|
||||
debug!(action = "stderr"; "{}", String::from_utf8_lossy(&buf));
|
||||
lines.extend(buf.clone());
|
||||
lines.push(b'\n');
|
||||
debug!(action = "stderr"; "{}", &line[0..line.len() - 1]);
|
||||
lines.extend(line.as_bytes().to_vec());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -207,9 +207,6 @@ fn build_dev_app<F: FnOnce(ExitStatus, ExitReason) + Send + 'static>(
|
||||
break;
|
||||
}
|
||||
let _ = io_stderr.write_all(&buf);
|
||||
if !buf.ends_with(&[b'\r']) {
|
||||
let _ = io_stderr.write_all(b"\n");
|
||||
}
|
||||
lines.push(String::from_utf8_lossy(&buf).into_owned());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,6 +24,7 @@ use std::io::{BufReader, Write};
|
||||
use std::process::{exit, Command, ExitStatus, Output, Stdio};
|
||||
use std::{
|
||||
ffi::OsString,
|
||||
io::BufRead,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
@@ -226,16 +227,15 @@ impl CommandExt for Command {
|
||||
let stdout_lines = Arc::new(Mutex::new(Vec::new()));
|
||||
let stdout_lines_ = stdout_lines.clone();
|
||||
std::thread::spawn(move || {
|
||||
let mut buf = Vec::new();
|
||||
let mut line = String::new();
|
||||
let mut lines = stdout_lines_.lock().unwrap();
|
||||
loop {
|
||||
buf.clear();
|
||||
if let Ok(0) = tauri_utils::io::read_line(&mut stdout, &mut buf) {
|
||||
line.clear();
|
||||
if let Ok(0) = stdout.read_line(&mut line) {
|
||||
break;
|
||||
}
|
||||
debug!(action = "stdout"; "{}", String::from_utf8_lossy(&buf));
|
||||
lines.extend(buf.clone());
|
||||
lines.push(b'\n');
|
||||
debug!(action = "stdout"; "{}", &line[0..line.len() - 1]);
|
||||
lines.extend(line.as_bytes().to_vec());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -243,16 +243,15 @@ impl CommandExt for Command {
|
||||
let stderr_lines = Arc::new(Mutex::new(Vec::new()));
|
||||
let stderr_lines_ = stderr_lines.clone();
|
||||
std::thread::spawn(move || {
|
||||
let mut buf = Vec::new();
|
||||
let mut line = String::new();
|
||||
let mut lines = stderr_lines_.lock().unwrap();
|
||||
loop {
|
||||
buf.clear();
|
||||
if let Ok(0) = tauri_utils::io::read_line(&mut stderr, &mut buf) {
|
||||
line.clear();
|
||||
if let Ok(0) = stderr.read_line(&mut line) {
|
||||
break;
|
||||
}
|
||||
debug!(action = "stderr"; "{}", String::from_utf8_lossy(&buf));
|
||||
lines.extend(buf.clone());
|
||||
lines.push(b'\n');
|
||||
debug!(action = "stderr"; "{}", &line[0..line.len() - 1]);
|
||||
lines.extend(line.as_bytes().to_vec());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user