Dotenv: Make a cli version to facilitate npm scripts better?

Created on 8 Feb 2018  路  4Comments  路  Source: motdotla/dotenv

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?

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samayo picture samayo  路  3Comments

acharotariya picture acharotariya  路  3Comments

shai32 picture shai32  路  5Comments

marcusradell picture marcusradell  路  3Comments

datasmurfen picture datasmurfen  路  5Comments