Skip to content

Commit d958da6

Browse files
committed
don't install plugins in excluded groups
1 parent 70d6e5d commit d958da6

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

bundler/lib/bundler/plugin.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def gemfile_install(gemfile = nil, unlock: false, &inline)
118118
Installer.new.install_definition(definition)
119119
end
120120

121-
plugins = definition.dependencies.map(&:name)
121+
plugins = definition.requested_dependencies.select(&:should_include?).map(&:name)
122122
installed_specs = plugins.to_h {|p| [p, definition.specs[p].first] }
123123

124124
save_plugins plugins, installed_specs, builder.inferred_plugins

bundler/spec/plugins/install_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,44 @@ def exec(command, args)
263263
expect(out).to include("Bundle complete!")
264264
end
265265

266+
it "installs plugins in included groups" do
267+
gemfile <<-G
268+
source '#{file_uri_for(gem_repo2)}'
269+
group :development do
270+
plugin 'foo'
271+
end
272+
gem 'rack', "1.0.0"
273+
G
274+
275+
bundle "install"
276+
277+
expect(out).to include("Installed plugin foo")
278+
279+
expect(out).to include("Bundle complete!")
280+
281+
expect(the_bundle).to include_gems("rack 1.0.0")
282+
plugin_should_be_installed("foo")
283+
end
284+
285+
it "does not install plugins in excluded groups" do
286+
gemfile <<-G
287+
source '#{file_uri_for(gem_repo2)}'
288+
group :development do
289+
plugin 'foo'
290+
end
291+
gem 'rack', "1.0.0"
292+
G
293+
294+
bundle "install --without development"
295+
296+
expect(out).not_to include("Installed plugin foo")
297+
298+
expect(out).to include("Bundle complete!")
299+
300+
expect(the_bundle).to include_gems("rack 1.0.0")
301+
plugin_should_not_be_installed("foo")
302+
end
303+
266304
it "upgrade plugins version listed in gemfile" do
267305
update_repo2 do
268306
build_plugin "foo", "1.4.0"

0 commit comments

Comments
 (0)