fix: handle versions with dots

This commit is contained in:
daimond113 2024-10-06 23:50:58 +02:00
parent 962482962b
commit 36d9ca0634
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 9 additions and 8 deletions

View file

@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Add support for multiple targets under the same package name in workspace members by @daimond113
### Fixed
- Fix versions with dots not being handled correctly by @daimond113
## [0.5.0-rc.1] - 2024-10-06
### Changed

View file

@ -1,10 +1,9 @@
use std::{fs::create_dir_all, io::Read, path::PathBuf};
use anyhow::Context;
use colored::Colorize;
use reqwest::header::ACCEPT;
use semver::Version;
use serde::Deserialize;
use std::{fs::create_dir_all, io::Read, path::PathBuf};
use crate::cli::{
bin_dir,
@ -160,9 +159,7 @@ pub fn get_or_download_version(
let path = home_dir()?.join("versions");
create_dir_all(&path).context("failed to create versions directory")?;
let path = path
.join(version.to_string())
.with_extension(std::env::consts::EXE_EXTENSION);
let path = path.join(format!("{version}{}", std::env::consts::EXE_SUFFIX));
let is_requested_version = *version == current_version();
@ -225,9 +222,11 @@ pub fn max_installed_version() -> anyhow::Result<Version> {
}
pub fn update_bin_exe() -> anyhow::Result<()> {
let copy_to = bin_dir()?
.join(env!("CARGO_BIN_NAME"))
.with_extension(std::env::consts::EXE_EXTENSION);
let copy_to = bin_dir()?.join(format!(
"{}{}",
env!("CARGO_BIN_NAME"),
std::env::consts::EXE_SUFFIX
));
std::fs::copy(std::env::current_exe()?, &copy_to)
.context("failed to copy executable to bin folder")?;