@bifravst/from-env
Version:
Helper function which ensures that required environment variables are set.
32 lines (21 loc) • 1.5 kB
Markdown
# fromEnv [](https://www.npmjs.com/package/@bifravst/from-env)
[](https://github.com/bifravst/from-env/actions)
[](https://github.com/semantic-release/semantic-release)
[](https://renovatebot.com)
[](https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional)
[](https://github.com/prettier/prettier/)
[](https://github.com/typescript-eslint/typescript-eslint)
Helper function which ensures that required environment variables are set.
## Example
```typescript
import { fromEnv } from "@bifravst/from-env";
const { env } = fromEnv({
env: "MY_ENV",
})(process.env);
```
This will throw an exception if `MY_ENV` is not set on `process.env`. Otherwise,
`env` will not contain the value of `process.env.MY_ENV`.
## Installation
npm i --save-dev --save-exact @bifravst/from-env
## Usage
See [`fromEnv.spec.ts`](./src/fromEnv.spec.ts).