Skip to content

Commit

Permalink
fix: parse booleans (#7922)
Browse files Browse the repository at this point in the history
fix boolean parsing
  • Loading branch information
alexghr authored Aug 12, 2024
1 parent ff4bb4f commit 65583e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions yarn-project/foundation/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping, 'par
*/
export function booleanConfigHelper(
defaultVal = false,
): Required<Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'>> {
): Required<Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & { parseVal: (val: string) => boolean }> {
const parse = (val: string | boolean) => (typeof val === 'boolean' ? val : ['1', 'true', 'TRUE'].includes(val));
return {
parseEnv: (val: string) => ['1', 'true', 'TRUE'].includes(val),
parseEnv: parse,
parseVal: parse,
defaultValue: defaultVal,
isBoolean: true,
};
Expand Down

0 comments on commit 65583e3

Please sign in to comment.