-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add dotenv support to dispatch run
and dispatch login
commands
#57
Conversation
I think that it would be super useful to add test coverage for the feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm understanding correctly, the priority order will be:
- command line
- local env vars
- .env file
Is that right?
I would prefer to either make the option local to the commands it applies to, or always load the file if it's a global option. I like the "always available" if possible, it keeps the mental model simple, but also fine if we pick the other approach as a first step.
Yes, that's correct |
The option is always global now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move env_file.go into config.go and get this merged!
Nice work 👏
I've just made last changes and tested. It's ready for merge now |
This PR adds a
--env-file
option support similar to recently introduced Node.js's--env-file
.Later, when we can add this file to
dispatch init
under some flags to autogenerate this file and avoid explicit export of environment variables for local development. It's also could be handy for adding rules likemake run-local
which run project against local development environment and other situation.github.com/joho/godotenv
behavior). I think this correct behavior, but it worth disacussingI've realized to only override env variables onThe option is global and it always loads a file when providedPreRunE
Cobra hook to avoid FS operations on dispatch commands other thanrun
andlogin
to make them work faster, but I can change that to always load config as @achille-roussel proposed. The--env-file
is a global option at the moment. We may want to make it non-global or leave it global and always load config. cc @achille-roussel