52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/kompo/tasks/bundle_install.rb', line 52
def run
work_dir = WorkDir.path
ruby_major_minor = InstallRuby.ruby_major_minor
@bundle_ruby_dir = File.join(work_dir, "bundle", "ruby", "#{ruby_major_minor}.0")
@bundler_config_path = File.join(work_dir, ".bundle", "config")
kompo_cache = Taski.args.fetch(:kompo_cache, File.expand_path("~/.kompo/cache"))
ruby_version = InstallRuby.ruby_version
version_cache_dir = File.join(kompo_cache, ruby_version)
bundle_cache_name = compute_bundle_cache_name
raise "Gemfile.lock not found in #{work_dir}" unless bundle_cache_name
cache_dir = File.join(version_cache_dir, bundle_cache_name)
group("Restoring bundle from cache") do
FileUtils.rm_rf(File.join(work_dir, "bundle")) if Dir.exist?(File.join(work_dir, "bundle"))
FileUtils.rm_rf(File.join(work_dir, ".bundle")) if Dir.exist?(File.join(work_dir, ".bundle"))
FileUtils.cp_r(File.join(cache_dir, "bundle"), File.join(work_dir, "bundle"))
FileUtils.cp_r(File.join(cache_dir, ".bundle"), File.join(work_dir, ".bundle"))
puts "Restored from: #{cache_dir}"
end
puts "Bundle restored from cache"
end
|