From 57119f9f17cf27499bd95e61c2f72d18314f11ba Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Sat, 29 Feb 2020 12:32:38 -0800 Subject: [PATCH] fix: normalized keys were not enumerable (#247) --- index.js | 1 + test/yargs-parser.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/index.js b/index.js index 0c5ad4e9..0e7448c2 100644 --- a/index.js +++ b/index.js @@ -465,6 +465,7 @@ function parse (args, opts) { const keys = [key].concat(flags.aliases[key] || []) keys.forEach(function (key) { Object.defineProperty(argvReturn, key, { + enumerable: true, get () { return val }, diff --git a/test/yargs-parser.js b/test/yargs-parser.js index 0fd4c6f0..6b22360a 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -342,6 +342,16 @@ describe('yargs-parser', function () { a.should.have.property('s').and.deep.equal(expected) a.should.have.property('save').and.deep.equal(expected) }) + + it('should allow normalized keys to be enumerated', () => { + var a = parser(['-s', ['', 'tmp', '..', ''].join(path.sep)], { + alias: { + s: ['save'] + }, + normalize: 's' + }) + Object.keys(a).should.include('s') + }) }) describe('alias', function () {