mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-16 22:06:43 -06:00
16 lines
298 B
Ruby
16 lines
298 B
Ruby
module EnvHelper
|
|
class << self
|
|
def with_env_var(key, val, &block)
|
|
was_defined = ENV.key? 'key'
|
|
old_value = ENV['key']
|
|
ENV[key] = val
|
|
block.call
|
|
ensure
|
|
if was_defined
|
|
ENV[key] = old_value
|
|
else
|
|
ENV.delete(key)
|
|
end
|
|
end
|
|
end
|
|
end
|