Skip to content

Commit 5f43198

Browse files
committed
WIP2
1 parent 01e1dae commit 5f43198

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/spring/application.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,18 @@ def run
134134
end
135135

136136
def with_env_vars(env)
137-
# Delete all env vars which are unchanged from before spring started
138-
original_env.each { |k, v| ENV.delete k if ENV[k] == v }
137+
# Allowed are keys currently not in ENV...
138+
allowed_keys = env.keys - ENV.keys
139+
# ...and ENV-keys whose values have not changed since the start of spring
140+
allowed_keys += original_env.select {|k, v| ENV[k] == v }.keys
141+
allowed_keys -= %w(RUBYOPT BUNDLE_GEMFILE)
142+
allowed_keys.uniq!
139143

140-
changed_keys = env.keys - ENV.keys
141-
# Load in the current env vars, except those which *were* changed when spring started
142-
env.each { |k, v| ENV[k] ||= v }
144+
allowed_keys.each{|k| ENV[k] = env[k] }
143145

144146
yield
145147
ensure
146-
changed_keys.each do |k|
148+
allowed_keys.each do |k|
147149
original_env.has_key?(k) ? ENV[k] = original_env[k] : ENV.delete(k)
148150
end
149151
end

0 commit comments

Comments
 (0)