Skip to content

Commit 1cb1b15

Browse files
committed
[rubygems/rubygems] Added --bundle option for triggering bundle install automatically after bundle gem
rubygems/rubygems@59ac0db26b
1 parent e6a6a35 commit 1cb1b15

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/bundler/cli/gem.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def run
6868
test: options[:test],
6969
ext: extension,
7070
exe: options[:exe],
71+
bundle: options[:bundle],
7172
bundler_version: bundler_dependency_version,
7273
git: use_git,
7374
github_username: github_username.empty? ? "[USERNAME]" : github_username,
@@ -258,6 +259,13 @@ def run
258259
IO.popen(%w[git add .], { chdir: target }, &:read)
259260
end
260261

262+
if config[:bundle]
263+
Bundler.ui.info "Running bundle install in the new gem directory."
264+
Dir.chdir(target) do
265+
system("bundle install")
266+
end
267+
end
268+
261269
# Open gemspec in editor
262270
open_editor(options["edit"], target.join("#{name}.gemspec")) if options[:edit]
263271

spec/bundler/commands/newgem_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def ignore_paths
4747
git("config --global github.user bundleuser")
4848

4949
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__LINTER" => "false",
50-
"BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false"
50+
"BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false", "BUNDLE_GEM__BUNDLE" => "false"
5151
end
5252

5353
describe "git repo initialization" do
@@ -161,6 +161,26 @@ def ignore_paths
161161
end
162162
end
163163

164+
shared_examples_for "--bundle flag" do
165+
before do
166+
bundle "gem #{gem_name} --bundle"
167+
end
168+
it "generates a gem skeleton with bundle install" do
169+
gem_skeleton_assertions
170+
expect(Kernel).to receive(:system).with("bundle", "install").once
171+
end
172+
end
173+
174+
shared_examples_for "--no-bundle flag" do
175+
before do
176+
bundle "gem #{gem_name} --no-bundle"
177+
end
178+
it "generates a gem skeleton without bundle install" do
179+
gem_skeleton_assertions
180+
expect(Kernel).not_to receive(:system).with("bundle", "install")
181+
end
182+
end
183+
164184
shared_examples_for "--rubocop flag" do
165185
context "is deprecated" do
166186
before do

0 commit comments

Comments
 (0)