Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to .env file like dotenv in Node #62

Open
slvrtrn opened this issue Nov 16, 2021 · 1 comment
Open

Fallback to .env file like dotenv in Node #62

slvrtrn opened this issue Nov 16, 2021 · 1 comment

Comments

@slvrtrn
Copy link

slvrtrn commented Nov 16, 2021

First of all, thanks for the fantastic library!

馃挕 Feature description

I think it would've been great to support dotenv-like behavior in envy.
That Node library can read environment variables from either environment variables directly (like envy does) or via .env file, which is super convenient during the local development, cause we can have .env.example with some default values for the development environment.

馃捇 Basic example

As an example, I can provide my own pet project where I played around with envy to actually make it work as I want.

As you can see, in load_config we, first of all, try to load env variables as usual with envy and if it fails, we try to load and parse .env file into the environment variables and re-read them again. And only after that, the final fail happens. This way, I can run the project from CLion without any additional configuration and explicit default values in the code.

Of course, it could be re-implemented in a different way, if it was to become a part of envy.

@rhrn
Copy link

rhrn commented Feb 22, 2023

@slvrtrn You can do own logic before parse. #65
#65 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants