dotenv-org / dotenv-vault

sync .env files—from the creator of `dotenv`.
https://www.dotenv.org
MIT License
1.14k stars 32 forks source link

Run arbitrary command with env vars #174

Open hbriese opened 1 year ago

hbriese commented 1 year ago

Is there a way to run an arbitrary command with the dotenv-vault env vars injected?

e.g.

dotenv-vault ?something? -- echo $MY_VAR

We currently use dotenv-cli for this purpose

motdotla commented 1 year ago

No, but there should be. Adding to our TODOs. We will try to have this ready by the end of the month.

hbriese commented 1 year ago

Any update on this?

devidw commented 1 year ago

This would be a great thing especially in monorepos to avoid the integration in all apps/packages with links to the root .env.vault

Instead, we could run app/package scripts directly from the mono repo manager like turbo or nx (even package manager like pnpm) and prefix it with the dotenv-vault command.

hbriese commented 1 year ago

I created dotenv-vault-core-cli to achieve this

npx dotenv-vault-core-cli -e .env -- my-script

The sooner the package is made irrelevant by upstream changes the better

Update

You can now use dotenv-cli instead, with dotenv >= 16.1.0 dotenv-vault-core-cli has been deprecated

motdotla commented 1 year ago

It's been many months and we haven't gotten to this.

Everyone, please use @hbriese's library until we do.

Thank you @hbriese!

motdotla commented 1 year ago

Our priority at the moment is to add support for .env.vault decryption to dotenv directly. There is an RC candidate:

https://github.com/motdotla/dotenv/tree/v16.1.0-rc1