Skip to content

Commit

Permalink
fix: pass flag to default function (#691)
Browse files Browse the repository at this point in the history
* fix: pass flag to default function

@W-11868418@

* chore: revert inadvertent change

* chore: add verbose to e2e test build

* chore: merge to verify fix
  • Loading branch information
peternhale authored May 3, 2023
1 parent 6ee41f9 commit 1cb7f26
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ const defaultFlagToCached = async (flag: CompletableOptionFlag<any>, isWritingMa
// if not specified, try the default function
if (typeof flag.default === 'function') {
try {
return await flag.default({options: {}, flags: {}}, isWritingManifest)
return await flag.default({options: flag, flags: {}}, isWritingManifest)
} catch {}
} else {
return flag.default
Expand Down
5 changes: 1 addition & 4 deletions src/parser/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,7 @@ export class Parser<T extends ParserInput, TFlags extends OutputFlags<T['flags']

if (!(k in flags) && flag.default !== undefined) {
this.metaData.flags[k] = {...this.metaData.flags[k], setFromDefault: true}
const defaultValue = (typeof flag.default === 'function' ? await flag.default({
options: flag,
flags, ...this.context,
}) : flag.default)
const defaultValue = (typeof flag.default === 'function' ? await flag.default({options: flag, flags}) : flag.default)
flags[k] = defaultValue
}
}
Expand Down
Loading

0 comments on commit 1cb7f26

Please sign in to comment.