From f76939f8c04a0ca59b7501bd27d749988ed5eff0 Mon Sep 17 00:00:00 2001 From: Dustin Blackman Date: Thu, 30 Nov 2023 21:53:57 -0500 Subject: [PATCH] feat: Add windows shims --- Cargo.toml | 1 - src/shims.rs | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e9a4bcf..a2515c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,6 @@ cargo-husky = { version = "1.5.0", default-features = false, features = ["user-h insta = { version = "1.31.0", features = ["yaml"] } [package.metadata.bin] -cargo-binstall = { version = "1.4.4" } cargo-cmd = { version = "0.3.1" } cargo-deny = { version = "0.13.5" } cargo-dist = { version = "0.1.0-prerelease.10" } diff --git a/src/shims.rs b/src/shims.rs index 96aa565..6858019 100644 --- a/src/shims.rs +++ b/src/shims.rs @@ -43,9 +43,21 @@ fi"# return Ok(()); } -// Shims not supported on Windows at the moment. #[cfg(not(target_family = "unix"))] -fn create_shim(_binary: &str, _bin_path: path::PathBuf) -> Result<()> { +fn create_shim(binary: &str, bin_path: path::PathBuf) -> Result<()> { + let script = format!( + r#"@echo off +cargo bin {binary} %* +"# + ); + + let mut f = fs::OpenOptions::new() + .create(true) + .write(true) + .open(bin_path)?; + + write!(f, "{}", script)?; + return Ok(()); }