Skip to content

Commit

Permalink
feat: Add windows shims
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Blackman committed Dec 1, 2023
1 parent 998841e commit f76939f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
16 changes: 14 additions & 2 deletions src/shims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}

Expand Down

0 comments on commit f76939f

Please sign in to comment.