From 3133b46991ef79f4db5142e9f75a18150436ebec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?iilei=20=E2=80=A2=20Jochen=20Preusche?= Date: Wed, 22 Aug 2018 19:21:40 +0200 Subject: [PATCH] Camel-Case-Expansion: alias by Property names, not Pathes This fixes issue #77 This *is* a breaking change --- index.js | 5 ++++- test/yargs-parser.js | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a3849bce..ab9710c9 100644 --- a/index.js +++ b/index.js @@ -371,7 +371,10 @@ function parse (args, opts) { unsetDefaulted(key) if (/-/.test(key) && configuration['camel-case-expansion']) { - addNewAlias(key, camelCase(key)) + var alias = key.split('.').map(function (prop) { + return camelCase(prop) + }).join('.') + addNewAlias(key, alias) } var value = processValue(key, val) diff --git a/test/yargs-parser.js b/test/yargs-parser.js index 29104246..be260e16 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -1115,6 +1115,15 @@ describe('yargs-parser', function () { argv.fooBar.should.equal(99) }) + + // Fixes: https://github.com/yargs/yargs-parser/issues/77 + it('should combine dot-notation and camel-case expansion', function () { + var argv = parser(['--dot-notation.foo.bar']) + + argv.should.satisfy(function (args) { + return args.dotNotation.foo.bar + }) + }) }) it('should define option as boolean and set default to true', function () {