use std::path::Path;
pub const SHIMS_DIR_NAME: &str = "shims";
pub const GH_SHIMS_DIR_ENV: &str = "AFT_GH_SHIMS_DIR";
pub const GH_SHIM_BINARY_ENV: &str = "AFT_GH_SHIM_BINARY";
pub const GH_SHIM_TICKET_ENV: &str = "AFT_GH_SHIM_TICKET";
pub const GH_SHIM_WORKER_ENV: &str = "AFT_GH_SHIM_WORKER";
pub fn windows_gh_cmd(binary: &Path) -> Vec<u8> {
let rendered = binary.to_string_lossy();
debug_assert!(!rendered.contains('"'));
let rendered = rendered.replace('%', "%%");
format!("@echo off\r\n\"{rendered}\" gh-shim %*\r\n").into_bytes()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn windows_wrapper_uses_the_explicit_gh_shim_dispatch_form() {
assert_eq!(
String::from_utf8(windows_gh_cmd(Path::new(r"C:\AFT Dev\aft.exe"))).unwrap(),
"@echo off\r\n\"C:\\AFT Dev\\aft.exe\" gh-shim %*\r\n"
);
}
}