2
2
const path = require ( 'path' ) ;
3
3
const buildParserOptions = require ( 'minimist-options' ) ;
4
4
const parseArguments = require ( 'yargs-parser' ) ;
5
- const camelCase = require ( 'camelcase' ) ;
6
5
const camelCaseKeys = require ( 'camelcase-keys' ) ;
7
6
const decamelizeKeys = require ( 'decamelize-keys' ) ;
8
7
const trimNewlines = require ( 'trim-newlines' ) ;
9
8
const redent = require ( 'redent' ) ;
10
9
const readPkgUp = require ( 'read-pkg-up' ) ;
11
10
const hardRejection = require ( 'hard-rejection' ) ;
12
11
const normalizePackageData = require ( 'normalize-package-data' ) ;
13
- const arrify = require ( 'arrify' ) ;
14
12
15
13
// Prevent caching of this module so module.parent is always accurate
16
14
delete require . cache [ __filename ] ;
@@ -69,7 +67,7 @@ const buildParserFlags = ({flags, booleanDefault}) =>
69
67
}
70
68
71
69
if ( flag . isMultiple ) {
72
- flag . type = 'array' ;
70
+ flag . type = flag . type ? ` ${ flag . type } -array` : 'array' ;
73
71
delete flag . isMultiple ;
74
72
}
75
73
@@ -78,15 +76,6 @@ const buildParserFlags = ({flags, booleanDefault}) =>
78
76
return parserFlags ;
79
77
} , { } ) ;
80
78
81
- /**
82
- Convert to alternative syntax for coercing values to expected type, according to https://github.com/yargs/yargs-parser#requireyargs-parserargs-opts.
83
- */
84
- const convertToTypedArrayOption = ( arrayOption , flags ) =>
85
- arrify ( arrayOption ) . map ( flagKey => ( {
86
- key : flagKey ,
87
- [ flags [ camelCase ( flagKey , '-' ) ] . type || 'string' ] : true
88
- } ) ) ;
89
-
90
79
const validateFlags = ( flags , options ) => {
91
80
for ( const [ flagKey , flagValue ] of Object . entries ( options . flags ) ) {
92
81
if ( flagKey !== '--' && ! flagValue . isMultiple && Array . isArray ( flags [ flagKey ] ) ) {
@@ -142,13 +131,6 @@ const meow = (helpText, options) => {
142
131
} ;
143
132
}
144
133
145
- if ( parserOptions . array !== undefined ) {
146
- // `yargs` supports 'string|number|boolean' arrays,
147
- // but `minimist-options` only support 'string' as element type.
148
- // Open issue to add support to `minimist-options`: https://github.com/vadimdemedes/minimist-options/issues/18.
149
- parserOptions . array = convertToTypedArrayOption ( parserOptions . array , options . flags ) ;
150
- }
151
-
152
134
const { pkg} = options ;
153
135
const argv = parseArguments ( options . argv , parserOptions ) ;
154
136
let help = redent ( trimNewlines ( ( options . help || '' ) . replace ( / \t + \n * $ / , '' ) ) , 2 ) ;
0 commit comments