File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -134,16 +134,19 @@ def run
134
134
end
135
135
136
136
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
+ # never allowed:
142
+ allowed_keys -= %w( RUBYOPT RUBY_ROOT BUNDLE_GEMFILE GEM_ROOT GEM_HOME GEM_PATH )
143
+ allowed_keys . uniq!
139
144
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 }
145
+ allowed_keys . each { |k | ENV [ k ] = env [ k ] }
143
146
144
147
yield
145
148
ensure
146
- changed_keys . each do |k |
149
+ allowed_keys . each do |k |
147
150
original_env . has_key? ( k ) ? ENV [ k ] = original_env [ k ] : ENV . delete ( k )
148
151
end
149
152
end
You can’t perform that action at this time.
0 commit comments