@@ -118,38 +118,25 @@ export function Run(
118
118
}
119
119
120
120
if ( switches . files ) {
121
- let files = switches . files ;
121
+ const files = switches . files ;
122
122
delete switches . files ;
123
123
124
- if ( Array . isArray ( files ) ) {
125
- files . forEach ( function ( s ) {
126
- args . push ( s ) ;
127
- } ) ;
128
- } else {
129
- args . push ( files ) ;
130
- }
131
-
132
- args . push ( '-r' ) ;
133
- args . push ( '-aoa' ) ;
124
+ const filesArray = Array . isArray ( files ) ? files : [ files ] ;
125
+ args = [ ...args , ...filesArray , '-r' , '-aoa' ] ;
134
126
}
135
127
136
128
// Add switches to the `args` array.
137
129
let switchesArray = Switches ( switches ) ;
138
- switchesArray . forEach ( function ( s ) {
139
- args . push ( s ) ;
140
- } ) ;
141
- // Remove now double quotes. If present in the spawned process 7-Zip will
142
- // read them as part of the paths (e.g.: create a `"archive.7z"` with
143
- // quotes in the file-name);
144
- args . forEach ( function ( e , i ) {
145
- if ( ! isString ( e ) ) {
146
- return ;
147
- }
130
+ args = [ ...args , ...switchesArray ] ;
148
131
149
- if ( e . substr ( 0 , 1 ) !== '-' ) {
150
- e = e . replace ( / ^ " / , '' ) ;
151
- e = e . replace ( / " $ / , '' ) ;
152
- args [ i ] = e ;
132
+ // Remove double quotes. If present in the spawned process, 7-Zip will
133
+ // read them as part of the path (e.g.: create a `"archive.7z"` with
134
+ // quotes in the file-name);
135
+ args . forEach ( function ( arg , i ) {
136
+ if ( ! isString ( arg ) ) return ;
137
+ const doubleQuotesMatch = arg . match ( / ^ \" ( .+ ) \" $ / ) ;
138
+ if ( doubleQuotesMatch ) {
139
+ args [ i ] = doubleQuotesMatch [ 1 ] ;
153
140
}
154
141
} ) ;
155
142
// Add bb2 to args array so we get file info
0 commit comments