Skip to content

Instantly share code, notes, and snippets.

@sethdavis512
Last active October 23, 2024 19:11
Show Gist options
  • Save sethdavis512/380f9e35a9ee974221108053052151f1 to your computer and use it in GitHub Desktop.
Save sethdavis512/380f9e35a9ee974221108053052151f1 to your computer and use it in GitHub Desktop.
function getEnvVariable(key: string): string {
if (key === undefined) {
throw Error(`"${key}" is undefined`);
}
const value = process.env[key];
if (!value) {
throw Error(
`Environment variable "${key}" does not exist on process.env`
);
}
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment