mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
* split tauri into 3 crates * fix macros * change builder into lib * cleanup package paths * add features back to lib * make build function public * add build-deps * rename and fix. * correct package name * move crates to root and refactor names * fix github action * move fixture to tauri-build * remove slash * add .vscode features * fix updater * fix updater mistake * fix(tauri) refactor buiilds * fix seperation * change get back to get * fix cfg and remove dead code warnings. * roll #160 into this pr * add credit * fix eof * chore(tauri) move assets to mod, loadAssets cfg outside its definition * chore(tauri) remove unused deps * update updater and cfg * fix(tauri) embedded-server with dead variable * add review refactors and remove cli form workgroup * chore(tauri) rename tauri to tauri-api and tauri-bundle to tauri * fix workspace and updater * rename update to updater
56 lines
1.6 KiB
Rust
56 lines
1.6 KiB
Rust
use std::process::{Child, Command, Stdio};
|
|
|
|
pub fn get_output(cmd: String, args: Vec<String>, stdout: Stdio) -> Result<String, String> {
|
|
Command::new(cmd)
|
|
.args(args)
|
|
.stdout(stdout)
|
|
.output()
|
|
.map_err(|err| err.to_string())
|
|
.and_then(|output| {
|
|
if output.status.success() {
|
|
return Result::Ok(String::from_utf8_lossy(&output.stdout).to_string());
|
|
} else {
|
|
return Result::Err(String::from_utf8_lossy(&output.stderr).to_string());
|
|
}
|
|
})
|
|
}
|
|
|
|
// TODO use .exe for windows builds
|
|
pub fn format_command(path: String, command: String) -> String {
|
|
return format!("{}/./{}", path, command);
|
|
}
|
|
|
|
pub fn relative_command(command: String) -> Result<String, std::io::Error> {
|
|
match std::env::current_exe()?.parent() {
|
|
Some(exe_dir) => return Ok(format_command(exe_dir.display().to_string(), command)),
|
|
None => {
|
|
return Err(std::io::Error::new(
|
|
std::io::ErrorKind::Other,
|
|
"Could not evaluate executable dir".to_string(),
|
|
))
|
|
}
|
|
}
|
|
}
|
|
|
|
// TODO append .exe for windows builds
|
|
pub fn command_path(command: String) -> Result<String, std::io::Error> {
|
|
match std::env::current_exe()?.parent() {
|
|
Some(exe_dir) => return Ok(format!("{}/{}", exe_dir.display().to_string(), command)),
|
|
None => {
|
|
return Err(std::io::Error::new(
|
|
std::io::ErrorKind::Other,
|
|
"Could not evaluate executable dir".to_string(),
|
|
))
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn spawn_relative_command(
|
|
command: String,
|
|
args: Vec<String>,
|
|
stdout: Stdio,
|
|
) -> Result<Child, std::io::Error> {
|
|
let cmd = relative_command(command)?;
|
|
Ok(Command::new(cmd).args(args).stdout(stdout).spawn()?)
|
|
}
|