Skip to content

Commit

Permalink
fix bug where custom flags have multiple=false (#414)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Donnalley <mdonnalley@salesforce.com>
  • Loading branch information
rolyatmax and mdonnalley authored Jul 14, 2022
1 parent 22ced3c commit 7337848
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function build<T>(defaults: Partial<OptionFlag<T>>): Definition<T> {
...defaults,
...options,
input: [] as string[],
multiple: Boolean(options.multiple),
multiple: Boolean(options.multiple === undefined ? defaults.multiple : options.multiple),
type: 'option',
} as any
}
Expand Down
8 changes: 8 additions & 0 deletions test/parser/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ See more help with --help`)
expect(out.flags.baz.toUpperCase()).to.equal('D')
expect(out.flags.bar.join('|')).to.equal('a|b')
})
it('parses multiple flags on custom flags', async () => {
const out = await parse(['--foo', 'a', '--foo=b'], {
flags: {
foo: flags.option({multiple: true, parse: async i => i}),
},
})
expect(out.flags).to.deep.include({foo: ['a', 'b']})
})
})

describe('strict: false', () => {
Expand Down

0 comments on commit 7337848

Please sign in to comment.