@@ -28,26 +28,17 @@ function retry(
28
28
archive : string
29
29
) {
30
30
// Start the command
31
- return Run ( '7z' , command , options , override )
32
- . progress ( function ( data : any ) {
33
- return progress ( onprogress ( data ) ) ;
34
- } ) // When all is done resolve the Promise.
35
- . then ( function ( args : string [ ] ) {
36
- return resolve ( args ) ;
37
- } ) // Catch the error and pass it to the reject function of the Promise.
38
- . catch ( function ( ) {
39
- console . error ( archive + ' failed using `7z`, retying with `7za`.' ) ;
40
- Run ( '7za' , command , options , override )
41
- . progress ( function ( data : any ) {
42
- return progress ( onprogress ( data ) ) ;
43
- } )
44
- . then ( function ( args : string [ ] ) {
45
- return resolve ( args ) ;
46
- } )
47
- . catch ( function ( err : any ) {
48
- return reject ( err ) ;
49
- } ) ;
31
+ let executables = [ '7z' , '7za' ] ;
32
+ const runner = ( ) => Run ( executables . shift ( ) , command , options , override )
33
+ . progress ( ( data : any ) => progress ( onprogress ( data ) ) )
34
+ . then ( ( args : string [ ] ) => resolve ( args ) ) // When all is done resolve the Promise.
35
+ . catch ( ( err : any ) => { // Catch the error and pass it to the reject function of the Promise.
36
+ if ( ! executables . length ) return reject ( err ) ;
37
+ console . error ( archive + ' failed using `' + executables [ 0 ] +
38
+ '`, retrying with `' + executables [ 1 ] + '`.' ) ;
39
+ runner ( ) ;
50
40
} ) ;
41
+ return runner ( ) ;
51
42
}
52
43
53
44
/**
0 commit comments