Closed jaidetree closed 6 months ago
i see what you are after. i personally don't recommend this. try to complete a worktree as soon as possible with .env changes and merge to main.
that said, you might find dotenvx more composable for your use case as it has built-in multi-environments.
Understandable. Thanks anyway
definitely give dotenvx a go. it has a beta mechanism that lets you commit your encrypted .env.vault with your code. this will essentially allow you to do what you want - tie secrets to a worktree.
After searching I found a similar issue: https://github.com/motdotla/dotenv/issues/256
But I do have a more specific use case: multiple worktrees
Given my project directory is setup as follows:
main, dev, and pr-review are separate worktrees
Ideally I'd like it if I could create a .env file in each worktree with something like:
While the original issue mentioned using the api to load multiple files, that is not as ideal:
This lets me set the default NODE_ENV which the outer .env may or may not override while overwriting the PORT for each worktree so I can run them simultaneously.
Happy to discuss further if you think there's a better solution I'm not seeing, and I'm willing to take a stab if you think it's worth exploring.