Skip to content

Commit

Permalink
feat: add "latest" as possible version (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats authored Jul 12, 2024
1 parent f99b7ed commit 2bca7ce
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ function parseVersionRange(version) {
return { range: "latest", isCanary: true };
}

if (version == "latest") {
return { range: "latest", isCanary: false };
}

if (GIT_HASH_RE.test(version)) {
return { range: version, isCanary: true };
}
Expand Down Expand Up @@ -92,6 +96,23 @@ async function resolveVersion({ range, isCanary }) {
return { version: range, isCanary: true };
}

if (range === "latest") {
const res = await fetchWithRetries(
"https://dl.deno.land/release-latest.txt",
);
if (res.status !== 200) {
throw new Error(
"Failed to fetch release version info from dl.deno.land. Please try again later.",
);
}
let version = (await res.text()).trim();
version = semver.clean(version);
if (version === null) {
return null;
}
return { version, isCanary: false };
}

const res = await fetchWithRetries("https://deno.com/versions.json");
if (res.status !== 200) {
throw new Error(
Expand Down

0 comments on commit 2bca7ce

Please sign in to comment.