@@ -117,24 +117,20 @@ export const deleteArchive =
117
117
// Convert array of files into a string if needed.
118
118
files = Files ( files ) ;
119
119
// Create a string that can be parsed by `run`.
120
- let command = ' d "' + filepath + '" ' + files ;
120
+ let command = ` d "${ filepath } " ${ files } ` ;
121
121
// Start the command
122
- Run ( '7z' , command , options , override ) // When all is done resolve the Promise.
123
- . then ( function ( args ) {
124
- return resolve ( args ) ;
125
- } ) // Catch the error and pass it to the reject function of the Promise.
126
- . catch ( function ( ) {
127
- console . error (
128
- 'DeleteArchive failed using `7z`, retying with `7za`.'
129
- ) ;
130
- Run ( '7za' , command , options , override )
131
- . then ( function ( args ) {
132
- return resolve ( args ) ;
133
- } )
134
- . catch ( function ( err ) {
135
- return reject ( err ) ;
136
- } ) ;
122
+ const executables = [ '7z' , '7za' ] ; // Two or more items
123
+ let position = 0 ;
124
+ const runner = ( ) => Run ( executables [ position ] , command , options , override )
125
+ . then ( ( args : any [ ] ) => resolve ( args ) ) // When all is done resolve the Promise.
126
+ . catch ( ( err : any ) => { // Catch the error and pass it to the reject function of the Promise.
127
+ if ( position === executables . length - 1 ) return reject ( err ) ;
128
+ console . error ( 'DeleteArchive failed using `' + executables [ position ] +
129
+ '`, retrying with `' + executables [ position + 1 ] + '`.' ) ;
130
+ position ++ ;
131
+ runner ( ) ;
137
132
} ) ;
133
+ return runner ( ) ;
138
134
} ) ;
139
135
} ) ;
140
136
0 commit comments