toddbluhm / env-cmd

Setting environment variables from a file
https://www.npmjs.com/package/env-cmd
MIT License
1.73k stars 65 forks source link

Feature request: specific --fallback location #345

Open scottsandersdev opened 2 years ago

scottsandersdev commented 2 years ago

I have a feature request - It would be nice if we could offer specific fallback files with the --fallback option. I really like that with env-cmd I can now put all of my projects env files in a /env folder. In my repo one of the first steps is to create a .env.local file and put the variables in there and then you can run the project.

However, there may be some people that clone the repo and don't need to create a dotenv file, they just want to run a default setup. In those cases it would be nice if I had a .env file in my /env folder that I could use as a fallback file. As it is now, I'd need to keep a .env file in the root of the project, apart from all the others in the /env folder.

Another optional way to do this is to pass an array of precedence, similar to how create react app uses .env files. So I could pass something like --precedence /env/.env.local /env/.env and whichever of the files is found is the one that is used.