-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Support loading multiple dotenvs #7943
Conversation
040cccf
to
732aa4c
Compare
732aa4c
to
da2275d
Compare
@@ -90,6 +90,9 @@ lane :deploy_all do | |||
end | |||
``` | |||
|
|||
And you can combine multiple envs in one go | |||
Ex: `fastlane build --env app1,env1,env2` will use `.env.app1` `.env.env1` and `.env.env2` |
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.
This should also be synced with https://github.com/fastlane/docs/blob/master/docs/faqs.md
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.
Those file look awfully similar. Are they meant to be the same? Why not sync them automatically?
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.
I will prepare a patch once this one is accepted.
env_file = File.join(base_path, ".env.#{env}") | ||
UI.success "Loading from '#{env_file}'" | ||
Dotenv.overload(env_file) | ||
if envs |
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.
Can we just use return if envs.nil?
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.
refactored
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.
Looking good, couple of general comments, but the api itself seems 👍
if env | ||
return unless envs | ||
|
||
envs = envs.split(",") # multiple envs? |
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.
Maybe call the arg "env_descriptor" or similar? Overwriting the var makes this harder to scan read
# Loads .env file for the environment(s) passed in through options | ||
envs = [envs] unless envs.kind_of? Array | ||
|
||
envs.each do |env| | ||
env_file = File.join(base_path, ".env.#{env}") |
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.
I'd break this out into a load_env(env)
fn for readability, because right now this fn is getting pretty complex
expect(ENV['DOTENV']).to eq(expected_value) | ||
ff = Fastlane::LaneManager.load_dot_env(envs) | ||
ENV.each do |k, v| | ||
puts "#{k} = #{v}" |
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.
This should be removed before merging
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.
doh!
02dc2a4
to
dfa7e44
Compare
dfa7e44
to
08e0df7
Compare
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.
LGTM
Things I am a bit unsure of:
--env
into--envs
Actions.lane_context[Actions::SharedValues::ENVIRONMENT]
should a new one be added with an array? should the original one keep the CSV passed on the CL?