@@ -121,13 +121,35 @@ async function main() {
121121
122122 const version = pkg . version ;
123123 const tag = `v${ version } ` ;
124- const assetName = `thanks-stars-${ tag } -${ target . triple } .${ target . ext } ` ;
125- const url = `https://github.com/Kenzo-Wada/thanks-stars/releases/download/${ tag } /${ assetName } ` ;
124+ const assetNameCandidates = [
125+ `thanks-stars-${ tag } -${ target . triple } .${ target . ext } ` ,
126+ `thanks-stars-${ target . triple } .${ target . ext } `
127+ ] ;
126128
127- const tempFile = path . join ( os . tmpdir ( ) , `${ assetName } ` ) ;
129+ const tempFile = path . join ( os . tmpdir ( ) , `thanks-stars- ${ target . triple } . ${ target . ext } ` ) ;
128130 try {
129- console . log ( `Downloading ${ url } ` ) ;
130- await download ( url , tempFile ) ;
131+ let downloadedAsset = null ;
132+ let lastError = null ;
133+ for ( const assetName of assetNameCandidates ) {
134+ const url = `https://github.com/Kenzo-Wada/thanks-stars/releases/download/${ tag } /${ assetName } ` ;
135+ console . log ( `Downloading ${ url } ` ) ;
136+ try {
137+ await download ( url , tempFile ) ;
138+ downloadedAsset = assetName ;
139+ break ;
140+ } catch ( error ) {
141+ lastError = error ;
142+ if ( error ?. message ?. includes ( '(status: 404)' ) ) {
143+ console . warn ( `Asset not found: ${ assetName } . Trying next candidate if available.` ) ;
144+ continue ;
145+ }
146+ throw error ;
147+ }
148+ }
149+
150+ if ( ! downloadedAsset ) {
151+ throw lastError ?? new Error ( 'Failed to download any release asset.' ) ;
152+ }
131153
132154 const binDir = path . join ( __dirname , 'bin' ) ;
133155 await extractArchive ( tempFile , binDir , target . ext ) ;
0 commit comments