Skip to content

Commit

Permalink
fix(commons): don’t convert env bools if null
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Oct 24, 2022
1 parent 7ba1f21 commit c4b4456
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions commons/lib/envUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ export function parseEnvPath(envvar: string, relativeTo?: string): string {
return Path.resolve(relativeTo ?? process.cwd(), envvar);
}

export function parseEnvBool(envvar: string): boolean {
export function parseEnvBool(envvar: string): boolean | undefined {
if (envvar === null || envvar === undefined) return undefined;
if (envvar === '1' || envvar?.toLowerCase() === 'true' || envvar?.toLowerCase() === 'yes')
return true;
return false;
if (envvar === '0' || envvar?.toLowerCase() === 'false' || envvar?.toLowerCase() === 'no') {
return false;
}
}

export function parseEnvBigint(envvar: string): bigint | null {
Expand Down

0 comments on commit c4b4456

Please sign in to comment.