@@ -10,6 +10,7 @@ import * as StreamZip from "node-stream-zip";
1010const streamFinished = util . promisify ( stream . finished ) ;
1111
1212const DENO_CANARY_INFO_URL = "https://dl.deno.land/canary-latest.txt" ;
13+ const DENO_RELEASE_INFO_URL = "https://dl.deno.land/release-latest.txt" ;
1314
1415// Example: https://github.com/denoland/deno/releases/download/v1.41.0/deno-aarch64-apple-darwin.zip
1516// Example: https://dl.deno.land/canary/d722de886b85093eeef08d1e9fd6f3193405762d/deno-aarch64-apple-darwin.zip
@@ -25,30 +26,39 @@ export interface DownloadInfo {
2526 url : string ;
2627 filename : string ;
2728 version : string ;
29+ canary : boolean ;
2830}
2931
30- export async function getDenoDownloadUrl ( ) : Promise < DownloadInfo > {
32+ export async function getDenoDownloadUrl (
33+ canary : boolean ,
34+ ) : Promise < DownloadInfo > {
3135 const key = `${ process . platform } ${ os . arch ( ) } ` ;
3236 if ( ! ( key in FILENAMES ) ) {
3337 throw new Error ( `Unsupported platform: ${ key } ` ) ;
3438 }
3539
3640 const name = FILENAMES [ key ] ;
3741
38- const res = await fetch ( DENO_CANARY_INFO_URL ) ;
42+ const url = canary ? DENO_CANARY_INFO_URL : DENO_RELEASE_INFO_URL ;
43+ const res = await fetch ( url ) ;
3944 if ( ! res . ok ) {
4045 await res . body ?. cancel ( ) ;
4146 throw new Error (
42- `${ res . status } : Unable to retrieve canary version information from ${ DENO_CANARY_INFO_URL } .` ,
47+ `${ res . status } : Unable to retrieve ${
48+ canary ? "canary" : "release"
49+ } version information from ${ url } .`,
4350 ) ;
4451 }
45- const sha = ( await res . text ( ) ) . trim ( ) ;
52+ const version = ( await res . text ( ) ) . trim ( ) ;
4653
4754 const filename = name + ".zip" ;
4855 return {
49- url : `https://dl.deno.land/canary/${ decodeURI ( sha ) } /${ filename } ` ,
56+ canary,
57+ url : canary
58+ ? `https://dl.deno.land/canary/${ decodeURI ( version ) } /${ filename } `
59+ : `https://dl.deno.land/release/${ decodeURI ( version ) } /${ filename } ` ,
5060 filename,
51- version : sha ,
61+ version : version ,
5262 } ;
5363}
5464
@@ -66,7 +76,9 @@ export async function downloadDeno(
6676 throw new Error ( `Unexpected empty body` ) ;
6777 }
6878
69- console . log ( `Downloading JSR binary...` ) ;
79+ console . log (
80+ `Downloading JSR ${ info . canary ? "canary" : "release" } binary...` ,
81+ ) ;
7082
7183 await withProgressBar (
7284 async ( tick ) => {
0 commit comments