Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "latest" as possible version #65

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 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,19 @@ 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.",
);
}
const version = (await res.text()).trim();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need to call version = semver.clean(version); like the below path. That seems stripping the leading v

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, probably we need to call semver.clean() to strip the leading v because v is prepended later here https://github.com/denoland/setup-deno/blob/main/src/install.js#L24

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good catch. fixed.

return { version, isCanary: false };
}

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