mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-17 14:26:45 -06:00
14 lines
259 B
Ruby
14 lines
259 B
Ruby
module TempEnvVarHelper
|
|
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
|