mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Merge pull request #104 from nabijaczleweli/main
Point links to just basename-ver, print them the right way 'round
This commit is contained in:
commit
856728b2c7
1 changed files with 14 additions and 6 deletions
20
src/bins.rs
20
src/bins.rs
|
@ -1,4 +1,4 @@
|
||||||
use std::path::PathBuf;
|
use std::path::{PathBuf, Path};
|
||||||
|
|
||||||
use cargo_toml::Product;
|
use cargo_toml::Product;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
@ -70,8 +70,8 @@ impl BinFile {
|
||||||
format!(
|
format!(
|
||||||
"{} ({} -> {})",
|
"{} ({} -> {})",
|
||||||
self.base_name,
|
self.base_name,
|
||||||
self.dest.display(),
|
self.link.display(),
|
||||||
self.link.display()
|
self.link_dest().display()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,18 +102,26 @@ impl BinFile {
|
||||||
std::fs::remove_file(&self.link)?;
|
std::fs::remove_file(&self.link)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let dest = self.link_dest();
|
||||||
debug!(
|
debug!(
|
||||||
"Create link '{}' pointing to '{}'",
|
"Create link '{}' pointing to '{}'",
|
||||||
self.link.display(),
|
self.link.display(),
|
||||||
self.dest.display()
|
dest.display()
|
||||||
);
|
);
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
std::os::unix::fs::symlink(&self.dest, &self.link)?;
|
std::os::unix::fs::symlink(dest, &self.link)?;
|
||||||
#[cfg(target_family = "windows")]
|
#[cfg(target_family = "windows")]
|
||||||
std::os::windows::fs::symlink_file(&self.dest, &self.link)?;
|
std::os::windows::fs::symlink_file(dest, &self.link)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn link_dest(&self) -> &Path {
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
{ Path::new(self.dest.file_name().unwrap()) }
|
||||||
|
#[cfg(target_family = "windows")]
|
||||||
|
{ &self.dest }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data required to get bin paths
|
/// Data required to get bin paths
|
||||||
|
|
Loading…
Add table
Reference in a new issue