@@ -60,36 +60,27 @@ async function getWeval() {
6060 }
6161
6262 await mkdir ( exeDir , { recursive : true } ) ;
63- let repoBaseURL = `https://api.github.com/repos/bytecodealliance/weval` ;
64- let response = await getJSON ( `${ repoBaseURL } /releases/tags/${ TAG } ` ) ;
65- let id = response . id ;
66- let assets = await getJSON ( `${ repoBaseURL } /releases/${ id } /assets` ) ;
67- let releaseAsset = `weval-${ TAG } -${ platformName } .${ assetSuffix } ` ;
68- let asset = assets . find ( asset => asset . name === releaseAsset ) ;
69- if ( ! asset ) {
70- console . error ( `Can't find an asset named ${ releaseAsset } ` ) ;
71- process . exit ( 1 ) ;
72- }
73- let data = await fetch ( asset . browser_download_url ) ;
74- if ( ! data . ok ) {
75- console . error ( `Error downloading ${ asset . browser_download_url } ` ) ;
76- process . exit ( 1 ) ;
77- }
78- let buf = await data . arrayBuffer ( ) ;
63+ const downloadUrl = `https://github.com/bytecodealliance/weval/releases/download/${ TAG } /weval-${ TAG } -${ platformName } .${ assetSuffix } ` ;
64+ let data = await fetch ( downloadUrl ) ;
65+ if ( ! data . ok ) {
66+ console . error ( `Error downloading ${ downloadUrl } ` ) ;
67+ process . exit ( 1 ) ;
68+ }
69+ let buf = await data . arrayBuffer ( ) ;
7970
80- if ( releaseAsset . endsWith ( '.xz' ) ) {
81- buf = await xz . decompress ( new Uint8Array ( buf ) ) ;
82- }
83- await decompress ( Buffer . from ( buf ) , exeDir , {
84- // Remove the leading directory from the extracted file.
85- strip : 1 ,
86- plugins : [
87- decompressUnzip ( ) ,
88- decompressTar ( )
89- ] ,
90- // Only extract the binary file and nothing else
91- filter : file => parse ( file . path ) . base === `weval${ exeSuffix } ` ,
92- } ) ;
71+ if ( downloadUrl . endsWith ( '.xz' ) ) {
72+ buf = await xz . decompress ( new Uint8Array ( buf ) ) ;
73+ }
74+ await decompress ( Buffer . from ( buf ) , exeDir , {
75+ // Remove the leading directory from the extracted file.
76+ strip : 1 ,
77+ plugins : [
78+ decompressUnzip ( ) ,
79+ decompressTar ( )
80+ ] ,
81+ // Only extract the binary file and nothing else
82+ filter : file => parse ( file . path ) . base === `weval${ exeSuffix } ` ,
83+ } ) ;
9384
9485 return exe ;
9586}
0 commit comments