0.2.0 • Published 8 years ago
dotenv-ex v0.2.0
dotenv-ex
- Loads environment variables from hierarchy of .env files for Node.js projects.
How to use it?
Use this somewhere possibly early in your program:
require('dotenv-ex')();this will load files based on NODE_ENV. If it's not set, production is used as default. The files are loaded in following order:
.env.production.local,.env.development.local.env.production,.env.development,.env.test.env.local.env
.env.local is not used in test environment, as well as there is no .env.test.local. This is because, I believe tests should not be specific to local environment, and should work for everyone working on the module, in the very same, reproducible way.
You can also override default files, by specifying only one file to load:
require('dotenv-ex')({env: '.env.one'})or your own list of files:
require('dotenv-ex')({env: ['.env.one', '.env.moar']})Keep in mind, that environment variables specified in the files, are case sensitive.
License
- Unlicense (~Public Domain)
Related Work
- https://github.com/motdotla/dotenv - used under-the-hood, even tho it discourages using multiple
.endfiles, let alone source controlling them - https://github.com/motdotla/dotenv-expand - also used, for variable expansion
- https://github.com/facebook/create-react-app -
react-scriptswas immediate source of inspiration - https://github.com/bkeepers/dotenv - hierarchy of
.envfiles based on this ruby gem
0.2.0
8 years ago