mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-02-23 08:04:52 +01:00
Add new_xplatform_command() helper in yaak-common that creates a tokio::process::Command with CREATE_NO_WINDOW flag set on Windows. Also converts git commands to async for consistency.
17 lines
508 B
Rust
17 lines
508 B
Rust
use std::ffi::OsStr;
|
|
|
|
#[cfg(target_os = "windows")]
|
|
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
|
|
|
/// Creates a new `tokio::process::Command` that won't spawn a console window on Windows.
|
|
pub fn new_xplatform_command<S: AsRef<OsStr>>(program: S) -> tokio::process::Command {
|
|
#[allow(unused_mut)]
|
|
let mut cmd = tokio::process::Command::new(program);
|
|
#[cfg(target_os = "windows")]
|
|
{
|
|
use std::os::windows::process::CommandExt;
|
|
cmd.creation_flags(CREATE_NO_WINDOW);
|
|
}
|
|
cmd
|
|
}
|