@@ -197,53 +197,61 @@ export async function downloadFromBinaries(
197
197
version ?: string
198
198
} ,
199
199
) {
200
- src = src . replace ( "{p}" , os . platform ( ) )
201
- const srcExt = path . extname ( src ) . toLowerCase ( )
202
- const srcUrl = `https://binaries.tonlabs.io/${ src } `
203
- terminal . write ( `Downloading from ${ srcUrl } ` )
204
- const dstDir = path . dirname ( dstPath )
205
- if ( ! fs . existsSync ( dstDir ) ) {
206
- fs . mkdirSync ( dstDir , { recursive : true } )
207
- }
208
- if ( srcExt === ".zip" ) {
209
- await downloadAndUnzip ( dstDir , srcUrl , terminal )
210
- } else if ( srcExt === ".gz" ) {
211
- await downloadAndGunzip ( dstPath , srcUrl , terminal )
212
- if ( path . extname ( dstPath ) === ".tar" ) {
213
- await run (
214
- "tar" ,
215
- [ "xvf" , dstPath ] ,
216
- { cwd : path . dirname ( dstPath ) } ,
217
- terminal ,
218
- )
219
- fs . unlink ( dstPath , ( ) => { } )
200
+ try {
201
+ console . log ( "TEST BRANCH" )
202
+ src = src . replace ( "{p}" , os . platform ( ) )
203
+ const srcExt = path . extname ( src ) . toLowerCase ( )
204
+ const srcUrl = `https://binaries.tonlabs.io/${ src } `
205
+ terminal . write ( `Downloading from ${ srcUrl } ` )
206
+ const dstDir = path . dirname ( dstPath )
207
+ if ( ! fs . existsSync ( dstDir ) ) {
208
+ fs . mkdirSync ( dstDir , { recursive : true } )
220
209
}
221
- } else {
222
- throw Error ( `Unexpected binary file extension: ${ srcExt } ` )
223
- }
224
- if ( options ?. executable && os . platform ( ) !== "win32" ) {
225
- if ( options ?. adjustedPath ) {
226
- const dir = path . dirname ( options . adjustedPath )
227
- fs . readdirSync ( dir )
228
- . map ( filename => path . resolve ( dir , filename ) )
229
- . filter ( filename => ! fs . lstatSync ( filename ) . isDirectory ( ) )
230
- . forEach ( filename => fs . chmodSync ( filename , 0o755 ) )
210
+ if ( srcExt === ".zip" ) {
211
+ await downloadAndUnzip ( dstDir , srcUrl , terminal )
212
+ } else if ( srcExt === ".gz" ) {
213
+ await downloadAndGunzip ( dstPath , srcUrl , terminal )
214
+ if ( path . extname ( dstPath ) === ".tar" ) {
215
+ await run (
216
+ "tar" ,
217
+ [ "xvf" , dstPath ] ,
218
+ { cwd : path . dirname ( dstPath ) } ,
219
+ terminal ,
220
+ )
221
+ fs . unlink ( dstPath , ( ) => { } )
222
+ }
231
223
} else {
232
- fs . chmodSync ( dstPath , 0o755 )
224
+ throw Error ( `Unexpected binary file extension: ${ srcExt } ` )
233
225
}
234
- // Without pause on Fedora 32 Linux always leads to an error: spawn ETXTBSY
235
- await new Promise ( resolve => setTimeout ( resolve , 100 ) )
236
- }
237
- if ( options ?. globally ) {
238
- if ( ! options . version ) {
239
- throw Error ( "Version required to install package" )
226
+ if ( options ?. executable && os . platform ( ) !== "win32" ) {
227
+ if ( options ?. adjustedPath ) {
228
+ const dir = path . dirname ( options . adjustedPath )
229
+ fs . readdirSync ( dir )
230
+ . map ( filename => path . resolve ( dir , filename ) )
231
+ . filter ( filename => ! fs . lstatSync ( filename ) . isDirectory ( ) )
232
+ . forEach ( filename => fs . chmodSync ( filename , 0o755 ) )
233
+ } else {
234
+ fs . chmodSync ( dstPath , 0o755 )
235
+ }
236
+ // Without pause on Fedora 32 Linux always leads to an error: spawn ETXTBSY
237
+ await new Promise ( resolve => setTimeout ( resolve , 100 ) )
240
238
}
241
- await installGlobally ( dstPath , options . version , terminal ) . catch ( err => {
242
- fs . unlink ( dstPath , ( ) => { } )
243
- throw err
244
- } )
239
+ if ( options ?. globally ) {
240
+ if ( ! options . version ) {
241
+ throw Error ( "Version required to install package" )
242
+ }
243
+ await installGlobally ( dstPath , options . version , terminal ) . catch (
244
+ err => {
245
+ fs . unlink ( dstPath , ( ) => { } )
246
+ throw err
247
+ } ,
248
+ )
249
+ }
250
+ terminal . write ( "\n" )
251
+ } catch ( err ) {
252
+ console . log ( err )
253
+ throw err
245
254
}
246
- terminal . write ( "\n" )
247
255
}
248
256
249
257
export function run (
@@ -289,7 +297,13 @@ export function run(
289
297
if ( code === 0 ) {
290
298
resolve ( output . join ( "" ) )
291
299
} else {
292
- reject ( `${ name } failed` )
300
+ reject (
301
+ Error (
302
+ terminal instanceof StringTerminal
303
+ ? terminal . stderr
304
+ : `${ name } failed` ,
305
+ ) ,
306
+ )
293
307
}
294
308
} )
295
309
} catch ( error ) {
0 commit comments