Skip to content

Commit 225de68

Browse files
committed
chore: normalize rust_version when comparing in update.ts
crates.io rust_version may be "1.84" (no patch); pad to MAJOR.MINOR.PATCH so @std/semver can parse it.
1 parent 1804f89 commit 225de68

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

scripts/update.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ async function updateRustToolchain(formatterVersion: string) {
140140
if (localMatch == null) {
141141
throw new Error("Could not find channel in local rust-toolchain.toml.");
142142
}
143+
// crates.io rust_version may be "1.84" (no patch); pad to MAJOR.MINOR.PATCH
144+
// so @std/semver can parse it.
145+
const normalize = (v: string) => /^\d+\.\d+$/.test(v) ? `${v}.0` : v;
143146
// only bump up; never downgrade. compare as semver so 1.95.0 > 1.92.0.
144-
const local = semver.parse(localMatch[1]);
145-
const required = semver.parse(requiredRustVersion);
147+
const local = semver.parse(normalize(localMatch[1]));
148+
const required = semver.parse(normalize(requiredRustVersion));
146149
if (semver.greaterThan(required, local)) {
147150
$.log(`Updating Rust toolchain: ${localMatch[1]} -> ${requiredRustVersion}`);
148151
toolchainPath.writeTextSync(localContent.replace(localMatch[0], `channel = "${requiredRustVersion}"`));

0 commit comments

Comments
 (0)