Last active
August 8, 2016 11:44
-
-
Save evanphx/5718074 to your computer and use it in GitHub Desktop.
Need to update a Gemfile.lock but don't want to install the gems? No problem! Run this in the same directory as your Gemfile!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'bundler' | |
gems = ARGV | |
if gems.empty? | |
puts "Updating all gems" | |
Bundler.definition(true) | |
else | |
puts "Updating gems: #{gems.join(', ')}" | |
lock = Bundler.read_file(Bundler.default_lockfile) | |
names = Bundler::LockfileParser.new(lock).specs.map{ |s| s.name } | |
Bundler.definition(:gems => gems, :sources => []) | |
end | |
d = Bundler.definition | |
puts "Resolving remotely..." | |
d.resolve_remotely! | |
d.lock(Bundler.default_lockfile) | |
puts "Updated lockfile!" | |
if Bundler.root.join("vendor/cache").exist? | |
puts "Downloading .gem's to update vendor/cache" | |
d.specs.sort_by { |s| s.full_name}.each do |s| | |
Bundler::Fetcher.fetch(s) | |
end | |
Bundler.load.cache | |
end | |
puts "Done! Enjoy!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment