So, I built a simple CLI that reads one or more .env files and spawns a new child process running an NPM script from the package, with the environment variables extended with the contents of the files.
It also supports expansion, where one file use the value defined in another file.
Please see the README for more details and usage and consider giving it a spin in your next project if you're faced with a similar problem.
Add these two lines to the top to use node executables and load the dotenv:
``` set dotenv-load := true export PATH := "./node_modules/.bin:" + env_var('PATH') ```
Fun fact: I actually lived with Casey (the maintainer) in a co-living space about 7 years ago. Small world ...
I especially like the package.json scripts for simple one-liners, if I have something complicated I might also create a ./scripts directory with a script and call that from an npm run-script.
I still use Makefiles everywhere in all of my projects. I like knowing I can have a consistent interface to everything with `make build`, `make run`, `make install`, etc.