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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify directory containing .env files #102

Closed
Stadly opened this issue Jan 19, 2024 · 3 comments
Closed

Specify directory containing .env files #102

Stadly opened this issue Jan 19, 2024 · 3 comments

Comments

@Stadly
Copy link

Stadly commented Jan 19, 2024

When using cascading env variables, you might end up with a lot of .env files. It is then common to group the .env files in a folder. Would it be possible to add a flag for specifying where dotenv should look for .env files? I suggest -d <dir>. For consistency, I think it should also work without -c, though that is probably the main use case.

# Load vars/.env (-d without -e or -c)
dotenv -d vars <cmd>

# Load vars/.env2 (-d combined with -e)
dotenv -d vars -e .env2 <cmd>

# Load env/.env.local and env/.env (-d combined with -c)
dotenv -d env -c <cmd>
@entropitor
Copy link
Owner

I see how that could be useful. I will accept a PR like this

@Stadly
Copy link
Author

Stadly commented Jan 22, 2024

After looking at the source code, I'm not sure -d is needed after all. Since -c cascades all files added with -e, the behavior provided by -d can already be achieved with the current functionality:

# Load vars/.env
dotenv -e vars/.env <cmd>

# Load vars/.env2
dotenv -e vars/.env2 <cmd>

# Load env/.env.local and env/.env (the use case I thought wasn't possible without -d)
dotenv -e env/.env -c <cmd>

What do you think?

@entropitor
Copy link
Owner

Yeah, I guess it might be better to keep the cli clean and lean and not add it. I guess if we really want to improve something, we could update the readme.

@entropitor entropitor closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
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