Skip to content

Instantly share code, notes, and snippets.

@euxn23
Last active July 22, 2024 08:46
Show Gist options
  • Select an option

  • Save euxn23/5c474611d78aab2ceb878042ecfb8e8e to your computer and use it in GitHub Desktop.

Select an option

Save euxn23/5c474611d78aab2ceb878042ecfb8e8e to your computer and use it in GitHub Desktop.
export function parseEnv(env: '1' | '0' | 'true' | 'false' | string | undefined): string | boolean {
if (!env) {
return false;
}
try {
return Boolean(JSON.parse(env));
} catch {
return env;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment