lib/slugbuilder/builder.rb in slugbuilder-3.1.0 vs lib/slugbuilder/builder.rb in slugbuilder-3.2.0
- old
+ new
@@ -26,21 +26,20 @@
yield(repo: @repo, git_ref: git_ref, git_url: @git_url)
end
end
def build(clear_cache: false, env: {}, prebuild: nil, postbuild: nil, slug_name: nil, buildpacks: Slugbuilder.config.buildpacks)
- @old_env = ENV.to_h
FileUtils.mkdir_p(@env_dir)
@buildpacks = buildpacks
@env = env.map { |k, v| [k.to_s, v.to_s] }.to_h
@slug_file = slug_name ? "#{slug_name}.tgz" : Shellwords.escape("#{@repo.gsub('/', '.')}.#{@git_ref}.#{@git_sha}.#{SecureRandom.hex}.tgz")
wipe_cache if clear_cache
prebuild.call(repo: @repo, git_ref: @git_ref, git_url: @git_url) if prebuild
- with_clean_env do
+ Bundler.with_clean_env do
build_and_release
end
stitle("Setup completed in #{@setup_time} seconds")
stitle("Build completed in #{@build_time} seconds")
stext("Application compiled in #{@compile_time} seconds")
@@ -64,26 +63,13 @@
FileUtils.rm_rf(@build_dir)
return true
rescue => e
stitle("Failed: #{e}\n")
return false
- ensure
- restore_env
end
private
-
- def restore_env
- ENV.delete_if { true }
- ENV.update(@old_env)
- end
-
- def with_clean_env
- ENV.delete_if { true }
- yield
- restore_env
- end
def wipe_cache
FileUtils.rm_rf(@cache_dir)
FileUtils.rm_rf(@buildpacks_dir)
FileUtils.mkdir_p(@cache_dir)