Skip to content

Commit

Permalink
Prevent naming collisions for unknown flags
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed May 19, 2020
1 parent 44e151a commit a3d5b26
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ class Parser {
})

this.#unknownFlags.forEach((flag, name) => {
let name = flag.name
let unknownName = flag.name
let count = 0
while (data.hasOwnProperty(name)) {
while (data.hasOwnProperty(unknownName)) {
count++
name = `${name}${count}`
unknownName = `${unknownName}${count}`
}

data[flag.name] = true
Object.defineProperty(sources, flag.name, {
data[unknownName] = true
Object.defineProperty(sources, unknownName, {
enumerable: true,
get() {
return flag
Expand Down

0 comments on commit a3d5b26

Please sign in to comment.