mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-15 15:16:37 +00:00
Fix compilation
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
6770f34ec4
commit
a30d61e5c4
1 changed files with 19 additions and 15 deletions
|
@ -4,7 +4,7 @@ use std::{
|
||||||
str,
|
str,
|
||||||
};
|
};
|
||||||
|
|
||||||
use tokio::process::Command;
|
use tokio::{io::AsyncWriteExt, process::Command};
|
||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
|
|
||||||
pub(super) async fn get() -> io::Result<Zeroizing<Box<str>>> {
|
pub(super) async fn get() -> io::Result<Zeroizing<Box<str>>> {
|
||||||
|
@ -56,18 +56,22 @@ pub(super) async fn get() -> io::Result<Zeroizing<Box<str>>> {
|
||||||
Ok(Zeroizing::new(password.into()))
|
Ok(Zeroizing::new(password.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to execute a command with input
|
trait CommandExt {
|
||||||
async fn output_async_with_stdin(
|
// Helper function to execute a command with input
|
||||||
cmd: &mut Command,
|
async fn output_async_with_stdin(&mut self, input: &[u8]) -> io::Result<Output>;
|
||||||
input: &[u8],
|
}
|
||||||
) -> io::Result<Output> {
|
|
||||||
let mut child = cmd.spawn()?;
|
|
||||||
let mut stdin = child.stdin.take().expect("Failed to open stdin");
|
|
||||||
|
|
||||||
tokio::spawn(async move {
|
impl CommandExt for Command {
|
||||||
use tokio::io::AsyncWriteExt;
|
async fn output_async_with_stdin(&mut self, input: &[u8]) -> io::Result<Output> {
|
||||||
let _ = stdin.write_all(input).await;
|
let mut child = self.spawn()?;
|
||||||
});
|
|
||||||
|
child
|
||||||
|
.stdin
|
||||||
|
.take()
|
||||||
|
.expect("Failed to open stdin")
|
||||||
|
.write_all(input)
|
||||||
|
.await?;
|
||||||
|
|
||||||
child.wait_with_output().await
|
child.wait_with_output().await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue