Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Nov 22, 2023
1 parent d0d8d98 commit 83eb97d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/core/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,18 @@ pub fn write_json_file_with_lock<T: Serialize>(
Ok(())
}

// Windows copies the file for bins
#[cfg(windows)]
pub fn remove_bin_file(path: impl AsRef<Path>) -> miette::Result<()> {
let path = path.as_ref();
let metadata = std::fs::symlink_metadata(path).into_diagnostic()?;
fs::remove_file(path)?;

// Unix uses symlinks for bins, while Windows copies the file
if metadata.is_symlink() {
fs::remove_link(path)?;
} else {
fs::remove_file(path)?;
}
Ok(())
}

// Unix uses symlinks for bins
#[cfg(not(windows))]
pub fn remove_bin_file(path: impl AsRef<Path>) -> miette::Result<()> {
fs::remove_link(path)?;

Ok(())
}

0 comments on commit 83eb97d

Please sign in to comment.