Skip to content

Commit

Permalink
feat: Do not build string switch with falsy values #102
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinrossetti committed Jul 11, 2021
1 parent 48a74d6 commit b7f799c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ const handle = flag => {
return `-${flag.cli}${suffix}`
},
string: flag => {
return `-${flag.cli}${flag.value}`
if (flag.value) {
return `-${flag.cli}${flag.value}`
} else {
return ''
}
},
stringArray: flag => {
const values = flag.value
Expand Down
8 changes: 8 additions & 0 deletions test/unit/flags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,13 @@ describe('Unit: flags.js', function () {
rawFake.map(arg => expect(r).to.include(arg))
expect(r).to.include('-bsp1')
})

it('should not add string values if only key is pecidied', function () {
const r = fromOptions({
password: false,
})
expect(r).not.to.includes('-p')
})

})
})

0 comments on commit b7f799c

Please sign in to comment.