|
| 1 | +# @code-like-a-carpenter/dotenv |
| 2 | + |
| 3 | +[](https://github.com/RichardLitt/standard-readme) |
| 4 | + |
| 5 | +> Wrapper around dotenv the loads the right .env file(s) based on the NODE_ENV |
| 6 | +
|
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +- [Install](#install) |
| 10 | +- [Usage](#usage) |
| 11 | +- [Maintainer](#maintainer) |
| 12 | +- [Contributing](#contributing) |
| 13 | +- [License](#license) |
| 14 | + |
| 15 | +## Install |
| 16 | + |
| 17 | +```bash |
| 18 | +npm i @code-like-a-carpenter/dotenv |
| 19 | +``` |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +This package uses the [dotenv](https://www.npmjs.com/package/dotenv) package |
| 24 | +under the hood, but, depending on `NODE_ENV`, will load more files than just the |
| 25 | +default `.env`. |
| 26 | + |
| 27 | +Each of the following files will be loaded if they exist, in the following |
| 28 | +order. Files loaded _earlier_ take precedence. |
| 29 | + |
| 30 | +- `.env.<env>.local` |
| 31 | +- `.env.local` |
| 32 | +- `.env.<env>` |
| 33 | +- `.env` |
| 34 | + |
| 35 | +There are only three valid values for `<env>`, based on the value of `NODE_ENV`: |
| 36 | + |
| 37 | +| `NODE_ENV` | `<env>` | |
| 38 | +| ------------- | ------------- | |
| 39 | +| `production` | `production` | |
| 40 | +| `test` | `test` | |
| 41 | +| anything else | `development` | |
| 42 | + |
| 43 | +Please add the following to your gitignore. `local` env files are intended for |
| 44 | +customizing the environment on your local machine and _should not_ be checked |
| 45 | +into git. |
| 46 | + |
| 47 | +```gitignore |
| 48 | +.env.local |
| 49 | +.env.*.local |
| 50 | +.env.production |
| 51 | +``` |
| 52 | + |
| 53 | +**Even though you may check env files into git, you still shouldn't check in |
| 54 | +secrets.** |
| 55 | + |
| 56 | +## Maintainer |
| 57 | + |
| 58 | +[Ian Remmel](https://www.ianwremmel.com) |
| 59 | + |
| 60 | +## Contributing |
| 61 | + |
| 62 | +Please see contributing guidelines at the |
| 63 | +[project homepage](https://www.github.com/code-like-a-carpenter/workbench/tree/main/packages/@code-like-a-carpenter/dotenv). |
| 64 | + |
| 65 | +## License |
| 66 | + |
| 67 | +MIT © [Ian Remmel](https://www.ianwremmel.com) 2023 until at least now |
0 commit comments