File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -28,14 +28,16 @@ function retry(
28
28
archive : string
29
29
) {
30
30
// Start the command
31
- let executables = [ '7z' , '7za' ] ;
32
- const runner = ( ) => Run ( executables . shift ( ) , command , options , override )
31
+ const executables = [ '7z' , '7za' ] ; // Two or more items
32
+ let position = 0 ;
33
+ const runner = ( ) => Run ( executables [ position ] , command , options , override )
33
34
. progress ( ( data : any ) => progress ( onprogress ( data ) ) )
34
35
. then ( ( args : string [ ] ) => resolve ( args ) ) // When all is done resolve the Promise.
35
36
. 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 ] + '`.' ) ;
37
+ if ( position === executables . length - 1 ) return reject ( err ) ;
38
+ console . error ( archive + ' failed using `' + executables [ position ] +
39
+ '`, retrying with `' + executables [ position + 1 ] + '`.' ) ;
40
+ position ++ ;
39
41
runner ( ) ;
40
42
} ) ;
41
43
return runner ( ) ;
You can’t perform that action at this time.
0 commit comments