fix(outdated): retain strict semver specifier when updating (#27701)

Fixes https://github.com/denoland/deno/issues/27697

If it's a strict bound (e.g. `1.0.0` as opposed to `^1.0.0` or other),
retain the strictness when we update
This commit is contained in:
Nathan Whitaker 2025-01-16 11:33:38 -08:00 committed by GitHub
parent 464ee9155e
commit 256950ddb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 27 additions and 21 deletions

View file

@ -280,9 +280,15 @@ fn choose_new_version_req(
if preferred.version <= resolved?.version {
return None;
}
let exact = if let Some(range) = dep.req.version_req.range() {
range.0[0].start == range.0[0].end
} else {
false
};
Some(
VersionReq::parse_from_specifier(
format!("^{}", preferred.version).as_str(),
format!("{}{}", if exact { "" } else { "^" }, preferred.version)
.as_str(),
)
.unwrap(),
)