1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 12:58:54 -05:00

fix(deno/upgrade): allow --version vX.Y.Z (#19139)

Instead of just supporting X.Y.Z, support vX.Y.Z. Otherwise we'll try to
download something like vvX.Y.Z
This commit is contained in:
Levente Kurusa 2023-05-16 03:21:59 +02:00 committed by GitHub
parent 27303ef688
commit ab9a17eeee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -294,6 +294,10 @@ pub async fn upgrade(
let install_version = match upgrade_flags.version {
Some(passed_version) => {
let re_hash = lazy_regex::regex!("^[0-9a-f]{40}$");
let passed_version = passed_version
.strip_prefix('v')
.unwrap_or(&passed_version)
.to_string();
if upgrade_flags.canary && !re_hash.is_match(&passed_version) {
bail!("Invalid commit hash passed");
@ -317,9 +321,9 @@ pub async fn upgrade(
{
log::info!("Version {} is already installed", crate::version::deno());
return Ok(());
} else {
passed_version
}
passed_version
}
None => {
let latest_version = if upgrade_flags.canary {
@ -363,7 +367,7 @@ pub async fn upgrade(
let download_url = if upgrade_flags.canary {
if env!("TARGET") == "aarch64-apple-darwin" {
bail!("Canary builds are not available for M1");
bail!("Canary builds are not available for M1/M2");
}
format!(