@@ -15,28 +15,30 @@ const processFlags = (flags) => {
15
15
let value = null ;
16
16
const isNoFlag = flags . includes ( "--no-" ) ;
17
17
18
- lodash
19
- . compact ( lodash . split ( flags , " " ) . map ( ( str ) => str . replace ( / , / g, "" ) ) )
20
- . forEach ( ( str ) => {
21
- if ( str . startsWith ( "-" ) ) {
22
- keys . push ( str ) ;
23
- } else if ( value === null ) {
24
- if ( str . startsWith ( "{" ) || str . startsWith ( "[" ) || str . startsWith ( "<" ) ) {
25
- const rawValue = str . replace ( / [ { [ < > } \] . ] / g, "" ) ;
26
- const variadic = str . includes ( "..." ) ;
27
- value = {
28
- raw : str ,
29
- variadic,
30
- name : rawValue ,
31
- formatter : optionFormatters [ rawValue ] || optionFormatters . string ,
32
- } ;
33
- }
18
+ const strArr = lodash . compact (
19
+ flags . split ( " " ) . map ( ( str ) => str . replace ( / , / g, "" ) ) ,
20
+ ) ;
21
+
22
+ for ( const str of strArr ) {
23
+ if ( str . startsWith ( "-" ) ) {
24
+ keys . push ( str ) ;
25
+ } else if ( value === null ) {
26
+ if ( str . startsWith ( "{" ) || str . startsWith ( "[" ) || str . startsWith ( "<" ) ) {
27
+ const rawValue = str . replace ( / [ { [ < > } \] . ] / g, "" ) ;
28
+ const variadic = str . includes ( "..." ) ;
29
+ value = {
30
+ raw : str ,
31
+ variadic,
32
+ name : rawValue ,
33
+ formatter : optionFormatters [ rawValue ] || optionFormatters . string ,
34
+ } ;
34
35
}
35
- } ) ;
36
+ }
37
+ }
36
38
37
39
const longestKey = keys . slice ( ) . sort ( ( a , b ) => b . length - a . length ) [ 0 ] ;
38
40
39
- if ( ! lodash . isEmpty ( longestKey ) ) {
41
+ if ( longestKey !== "" ) {
40
42
name = lodash . camelCase (
41
43
( isNoFlag ? longestKey . replace ( "--no-" , "" ) : longestKey ) . replace (
42
44
/ ( - - ? ) / ,
0 commit comments