feat: more package managers support

This commit is contained in:
iff 2024-12-07 22:26:10 +01:00
parent d10c3a55d3
commit aaad3a17b0
2 changed files with 99 additions and 34 deletions

View file

@ -173,12 +173,12 @@ pub fn get_error(shell: &str, command: &str) -> String {
std::env::remove_var("_PR_ERROR_MSG");
error_msg
} else {
command_output(shell, command)
command_output_threaded(shell, command)
};
error.split_whitespace().collect::<Vec<&str>>().join(" ")
}
pub fn command_output(shell: &str, command: &str) -> String {
pub fn command_output_threaded(shell: &str, command: &str) -> String {
let (sender, receiver) = channel();
let _shell = shell.to_owned();
@ -209,6 +209,17 @@ pub fn command_output(shell: &str, command: &str) -> String {
}
}
pub fn command_output(shell: &str, command: &str) -> String {
let output = std::process::Command::new(shell)
.arg("-c")
.arg(command)
.env("LC_ALL", "C")
.output()
.expect("failed to execute process");
String::from_utf8_lossy(&output.stdout).to_string()
}
pub fn last_command(shell: &str) -> String {
let last_command = match std::env::var("_PR_LAST_COMMAND") {
Ok(command) => command,