Although we could use node -r ... to have our .env populated into our environment, we don't necessarily want to run a node script?
Wouldn't it be nice if we make a simple CLI that reads the .env and then execute the command provided? For example, something like:
> cat .env
MESSAGE=hello world
> dotenv echo $MESSAGE
hello world
Not sure how feasible this is, but I think this would be a really cool feature to add on. Thoughts?
Well, although technically we could do something like
($(cat .env | xargs -n1 echo export) && echo $MONGO_URL)
like you've identified, bash-foo will likely win out but you could probably use zeit/pkg to wrap this module and distribute a CLI via npm... and as I checked to see if dotenv-cli is available, someone has done this https://www.npmjs.com/package/dotenv-cli
@maxbeatty instead of publishing another package, i was originally thinking to add a bin field to the package.json in dotenv so that we could support that.
I would be more inclined to explore if someone hadn鈥檛 already published a working solution