Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parsing the default is wrong types #380

Merged
merged 3 commits into from Feb 28, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/parser/parse.ts
Expand Up @@ -208,12 +208,8 @@ export class Parser<T extends ParserInput, TFlags extends OutputFlags<T['flags']
if (!(k in flags) && flag.default !== undefined) {
this.metaData.flags[k] = {setFromDefault: true}
// eslint-disable-next-line no-await-in-loop
const defaultValue = (typeof flag.default === 'function' ? await flag.default({options: flag, flags, ...this.context}) : flag.default) as string
const parsedValue = flag.type === 'option' && flag.parse ?
// eslint-disable-next-line no-await-in-loop
await flag.parse(defaultValue, this.context) :
defaultValue
flags[k] = parsedValue
const defaultValue = (typeof flag.default === 'function' ? await flag.default({options: flag, flags, ...this.context}) : flag.default)
flags[k] = defaultValue
}
}

Expand Down