File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -696,7 +696,7 @@ function parse (args, opts) {
696696 } )
697697 // For "--optionName", also set argv['option-name']
698698 flags . aliases [ key ] . concat ( key ) . forEach ( function ( x ) {
699- if ( / [ A - Z ] / . test ( x ) && configuration [ 'camel-case-expansion' ] ) {
699+ if ( x . length > 1 && / [ A - Z ] / . test ( x ) && configuration [ 'camel-case-expansion' ] ) {
700700 var c = decamelize ( x , '-' )
701701 if ( c !== key && flags . aliases [ key ] . indexOf ( c ) === - 1 ) {
702702 flags . aliases [ key ] . push ( c )
Original file line number Diff line number Diff line change @@ -1218,6 +1218,21 @@ describe('yargs-parser', function () {
12181218 result . should . have . property ( 'someOption' , 'asdf' )
12191219 } )
12201220
1221+ it ( 'should not apply camel-case logic to 1-character options' , function ( ) {
1222+ var result = parser ( [ '-p' , 'hello' ] , {
1223+ alias : {
1224+ p : 'parallel' ,
1225+ P : 'parallel-series'
1226+ }
1227+ } )
1228+
1229+ result . should . not . have . property ( 'P' , 'hello' )
1230+ result . should . not . have . property ( 'parallel-series' , 'hello' )
1231+ result . should . not . have . property ( 'parallelSeries' , 'hello' )
1232+ result . should . have . property ( 'parallel' , 'hello' )
1233+ result . should . have . property ( 'p' , 'hello' )
1234+ } )
1235+
12211236 it ( 'should provide aliases of options with dashes as camelCase properties' , function ( ) {
12221237 var result = parser ( [ ] , {
12231238 alias : {
You can’t perform that action at this time.
0 commit comments