@@ -328,32 +328,20 @@ export const listArchive =
328
328
329
329
// Create a string that can be parsed by `run`.
330
330
let command = 'l "' + filepath + '" ' ;
331
- Run ( isWindows ( ) ? '7z' : '7za' , command , options , override )
332
- . progress ( function ( data : string ) {
333
- return progress ( onprogress ( data ) ) ;
334
- } )
335
- . then ( function ( ) {
336
- return resolve ( spec ) ;
337
- } )
338
- . catch ( function ( err : any ) {
339
- if ( isWindows ( ) ) {
340
- console . error (
341
- 'ListArchive failed using `7z`, retying with `7za`.'
342
- ) ;
343
- Run ( '7za' , command , options , override )
344
- . progress ( function ( data : string ) {
345
- return progress ( onprogress ( data ) ) ;
346
- } )
347
- . then ( function ( args : any ) {
348
- return resolve ( args ) ;
349
- } )
350
- . catch ( function ( err : any ) {
351
- return reject ( err ) ;
352
- } ) ;
353
- } else {
354
- return reject ( err ) ;
355
- }
331
+ // Start the command
332
+ const executables = [ '7z' , '7za' ] ;
333
+ let position = isWindows ( ) ? 0 : 1 ; // Windows - 2 attempts, others - 1 attempt
334
+ const runner = ( ) => Run ( executables [ position ] , command , options , override )
335
+ . progress ( ( data : string ) => progress ( onprogress ( data ) ) )
336
+ . then ( ( args : any ) => resolve ( position === 1 && isWindows ( ) ? args : spec ) )
337
+ . catch ( ( err : any ) => {
338
+ if ( position === executables . length - 1 ) return reject ( err ) ;
339
+ console . error ( 'ListArchive failed using `' + executables [ position ] +
340
+ '`, retrying with `' + executables [ position + 1 ] + '`.' ) ;
341
+ position ++ ;
342
+ runner ( ) ;
356
343
} ) ;
344
+ return runner ( ) ;
357
345
} ) ;
358
346
} ) ;
359
347
0 commit comments