aboutsummaryrefslogtreecommitdiff
path: root/libs/nak/src/runtime_wrap.rs
blob: 37980d350d402cd9aa30638b24116fc171e0d722 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use std::ffi::OsStr;
use std::process::Command;

/// Build a command to run `exe` with the given environment variables.
pub fn build_command<S: AsRef<OsStr>>(
    exe: impl AsRef<OsStr>,
    envs: &[(&str, S)],
) -> Command {
    let mut cmd = Command::new(exe);
    for (key, value) in envs {
        cmd.env(key, value.as_ref());
    }
    cmd
}

/// Build a command with no extra environment variables.
pub fn command_for(exe: impl AsRef<OsStr>) -> Command {
    build_command::<&str>(exe, &[])
}