summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-06-02 18:16:12 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-06-04 23:26:51 -0500
commita633b683099e0bb59942d55072d4060241c324fd (patch)
tree626498d4669e8feb1be9325df83cf50f19ddfd30
parent667d4e4487bde5196bb326a7c03531e65de85cf6 (diff)
downloadbundler-seg-bundle-lock-add-platform.tar.gz
[Lock] Add --add-platformseg-bundle-lock-add-platform
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/lock.rb5
-rw-r--r--lib/bundler/definition.rb8
-rw-r--r--spec/commands/lock_spec.rb9
4 files changed, 21 insertions, 3 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index fe510d1734..bb21e6f4e5 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -425,6 +425,8 @@ module Bundler
"the path the lockfile should be written to"
method_option "full-index", :type => :boolean, :default => false, :banner =>
"Fall back to using the single-file index of all gems"
+ method_option "add-platform", :type => :array, :default => [], :banner =>
+ "add a new platform to the lockfile"
def lock
require "bundler/cli/lock"
Lock.new(options).run
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
index e95e9ff636..ba9a32655d 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -26,6 +26,11 @@ module Bundler
definition = Bundler.definition(true)
end
+ options["add-platform"].each do |platform|
+ platform = Gem::Platform.new(platform)
+ definition.add_platform(platform)
+ end
+
definition.resolve_remotely! unless options[:local]
if print
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 69ecd4fdcc..413eedc168 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -87,8 +87,7 @@ module Bundler
@unlock[:sources] ||= []
current_platform = Bundler.rubygems.platforms.map {|p| generic(p) }.compact.last
- @new_platform = !@platforms.include?(current_platform)
- @platforms |= [current_platform]
+ add_platform(current_platform)
@path_changes = converge_paths
eager_unlock = expand_dependencies(@unlock[:gems])
@@ -433,6 +432,11 @@ module Bundler
end
end
+ def add_platform(platform)
+ @new_platform ||= !@platforms.include?(platform)
+ @platforms |= [platform]
+ end
+
attr_reader :sources
private :sources
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index 7f32409ea6..b204c6aad5 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -42,7 +42,7 @@ describe "bundle lock" do
with_license (1.0)
PLATFORMS
- ruby
+ #{local}
DEPENDENCIES
foo
@@ -103,4 +103,11 @@ describe "bundle lock" do
expect(read_lockfile).to eq(@lockfile)
end
+
+ it "supports adding new platforms" do
+ bundle! "lock --add-platform java x86-mingw32"
+
+ lockfile = Bundler::LockfileParser.new(read_lockfile)
+ expect(lockfile.platforms).to eq([java, local, mingw])
+ end
end