@@ -35,17 +35,7 @@ Deno.remove(dropExtension(rclone), {recursive: true});
35
35
console . log ( "All dependencies fetched!" ) ;
36
36
37
37
async function releaseUrl ( org : string , repo : string , suffix ?: string ) : Promise < string > {
38
- let info = await releaseInfo ( org , repo ) ;
39
- const tag = info . tag_name . match ( / ( [ ^ 0 - 9 ] + ) ( .+ ) / ) ;
40
- if ( ! tag ) {
41
- console . error ( "Unexpected error parsing latest " + repo + " tag name!" ) ;
42
- Deno . exit ( 2 ) ;
43
- }
44
-
45
- const version = prompt ( repo + " version to download?" , tag [ 2 ] ) ;
46
- if ( version != tag [ 2 ] )
47
- info = await releaseInfo ( org , repo , tag [ 1 ] + version ) ;
48
-
38
+ const info = await promptVersion ( org , repo ) ;
49
39
if ( suffix ) {
50
40
// Download binary release.
51
41
const file = info . assets . find ( function ( each ) {
@@ -58,7 +48,22 @@ async function releaseUrl(org: string, repo: string, suffix?: string): Promise<s
58
48
return file . browser_download_url ;
59
49
} else
60
50
// Download source release.
61
- return "https://github.com/" + org + "/" + repo + "/archive/refs/tags/v" + version + ".tar.gz" ;
51
+ return "https://github.com/" + org + "/" + repo + "/archive/refs/tags/" + info . tag_name + ".tar.gz" ;
52
+ }
53
+
54
+ async function promptVersion ( org : string , repo : string ) : Promise < ReleaseInfo > {
55
+ let info = await releaseInfo ( org , repo ) ;
56
+ const tag = info . tag_name . match ( / ( [ ^ 0 - 9 ] + ) ( .+ ) / ) ;
57
+ if ( ! tag ) {
58
+ console . error ( "Unexpected error parsing latest " + repo + " tag name!" ) ;
59
+ Deno . exit ( 2 ) ;
60
+ }
61
+
62
+ const version = prompt ( repo + " version to download?" , tag [ 2 ] ) ;
63
+ if ( version != tag [ 2 ] )
64
+ info = await releaseInfo ( org , repo , tag [ 1 ] + version ) ;
65
+
66
+ return info ;
62
67
}
63
68
64
69
async function releaseInfo ( org : string , repo : string , tag = "" ) : Promise < ReleaseInfo > {
0 commit comments