File tree 1 file changed +8
-10
lines changed
simple-git/src/lib/plugins
1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -6,32 +6,30 @@ export function suffixPathsPlugin(): SimpleGitPlugin<'spawn.args'> {
6
6
type : 'spawn.args' ,
7
7
action ( data ) {
8
8
const prefix : string [ ] = [ ] ;
9
- const suffix : string [ ] = [ ] ;
10
- let suffixFound : boolean = false ;
9
+ let suffix : undefined | string [ ] ;
10
+ function append ( args : string [ ] ) {
11
+ ( suffix = suffix || [ ] ) . push ( ...args ) ;
12
+ }
11
13
12
14
for ( let i = 0 ; i < data . length ; i ++ ) {
13
15
const param = data [ i ] ;
14
16
15
17
if ( isPathSpec ( param ) ) {
16
- suffixFound = true ;
17
- suffix . push ( ...toPaths ( param ) ) ;
18
+ append ( toPaths ( param ) ) ;
18
19
continue ;
19
20
}
20
21
21
22
if ( param === '--' ) {
22
- suffixFound = true ;
23
- suffix . push (
24
- ...data
25
- . slice ( i + 1 )
26
- . flatMap ( ( item ) => ( isPathSpec ( item ) && toPaths ( item ) ) || item )
23
+ append (
24
+ data . slice ( i + 1 ) . flatMap ( ( item ) => ( isPathSpec ( item ) && toPaths ( item ) ) || item )
27
25
) ;
28
26
break ;
29
27
}
30
28
31
29
prefix . push ( param ) ;
32
30
}
33
31
34
- return suffixFound ? [ ...prefix , '--' , ...suffix . map ( String ) ] : prefix ;
32
+ return ! suffix ? prefix : [ ...prefix , '--' , ...suffix . map ( String ) ] ;
35
33
} ,
36
34
} ;
37
35
}
You can’t perform that action at this time.
0 commit comments