Skip to content

Commit 130ace4

Browse files
committed
deps.ts: Make releaseUrl() look for source archives when the binary suffix is omitted
1 parent 3fd8107 commit 130ace4

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

deps.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Deno.remove(dropExtension(rclone), {recursive: true});
3434

3535
console.log("All dependencies fetched!");
3636

37-
async function releaseUrl(org: string, repo: string, suffix: string): Promise<string> {
37+
async function releaseUrl(org: string, repo: string, suffix?: string): Promise<string> {
3838
let info = await releaseInfo(org, repo);
3939
const tag = info.tag_name.match(/([^0-9]+)(.+)/);
4040
if(!tag) {
@@ -46,14 +46,19 @@ async function releaseUrl(org: string, repo: string, suffix: string): Promise<st
4646
if(version != tag[2])
4747
info = await releaseInfo(org, repo, tag[1] + version);
4848

49-
const file = info.assets.find(function(each) {
50-
return each.name.endsWith(suffix);
51-
});
52-
if(!file) {
53-
console.error("Release " + version + " of " + repo + " not available for Linux!");
54-
Deno.exit(3);
55-
}
56-
return file.browser_download_url;
49+
if(suffix) {
50+
// Download binary release.
51+
const file = info.assets.find(function(each) {
52+
return each.name.endsWith(suffix);
53+
});
54+
if(!file) {
55+
console.error("Release " + info.tag_name + " of " + repo + " not available for Linux!");
56+
Deno.exit(3);
57+
}
58+
return file.browser_download_url;
59+
} else
60+
// Download source release.
61+
return "https://github.com/" + org + "/" + repo + "/archive/refs/tags/v" + version + ".tar.gz";
5762
}
5863

5964
async function releaseInfo(org: string, repo: string, tag = ""): Promise<ReleaseInfo> {

0 commit comments

Comments
 (0)