Skip to content

Commit 1bef381

Browse files
committed
Fix for double execution of bundle exec
1 parent da0418a commit 1bef381

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

Rakefile

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ RSpec::Core::RakeTask.new(:spec)
55

66
task default: :spec
77

8+
# To avoid double "bundle exec" calls, e.g. bundle exec ... in bundle exec rake ...
9+
def bundle_exec(command)
10+
Bundler.with_unbundled_env do
11+
sh "bundle exec #{command}"
12+
end
13+
end
14+
815
# We don't want to push tags to source control when releasing the gem
916
Rake::Task["release"].clear
1017

@@ -24,17 +31,19 @@ task :test_normal, [:skip_tag] do |_, args|
2431
rspec_opts = []
2532
rspec_opts << "--tag '~#{skip_tag}'" if skip_tag
2633

27-
sh "bundle exec rspec --exclude-pattern 'spec/line/bot/line_bot_api_gem_spec.rb,spec/line/bot/line_bot_gem_spec.rb' #{rspec_opts.join(' ')}"
34+
bundle_exec(
35+
"rspec --exclude-pattern 'spec/line/bot/line_bot_api_gem_spec.rb,spec/line/bot/line_bot_gem_spec.rb' #{rspec_opts.join(' ')}"
36+
)
2837
end
2938

3039
desc "Test line-bot-api gem spec"
3140
task :test_line_bot_api do
32-
sh "bundle exec rspec --pattern 'spec/line/bot/line_bot_api_gem_spec.rb'"
41+
bundle_exec("rspec --pattern 'spec/line/bot/line_bot_api_gem_spec.rb'")
3342
end
3443

3544
desc "Test line/bot gem(?) spec"
3645
task :test_line_bot do
37-
sh "bundle exec rspec --pattern 'spec/line/bot/line_bot_gem_spec.rb'"
46+
bundle_exec("rspec --pattern 'spec/line/bot/line_bot_gem_spec.rb'")
3847
end
3948

4049
desc "Run all tests in separate processes"
@@ -46,18 +55,18 @@ end
4655

4756
desc "Validate comment for YARD"
4857
task :validate_yard_comment do
49-
sh "bundle exec yard stats ./lib/line/bot/v2 --fail-on-warning"
58+
bundle_exec("yard stats ./lib/line/bot/v2 --fail-on-warning")
5059
end
5160

5261
desc "RBS type check"
5362
task :rbs do
54-
sh "bundle exec rbs collection install"
55-
sh "bundle exec rbs -I sig validate"
63+
bundle_exec("rbs collection install")
64+
bundle_exec("rbs -I sig validate")
5665
end
5766

5867
desc "RBS type check (with steep)"
5968
task :rbs_steep do
60-
sh "bundle exec steep check"
69+
bundle_exec("steep check")
6170
end
6271

6372
desc "RBS type check (with test)"
@@ -86,17 +95,17 @@ end
8695

8796
desc "Run rubocop"
8897
task :rubocop do
89-
sh "bundle exec rubocop"
98+
bundle_exec("rubocop")
9099
end
91100

92101
desc "Fix rubocop errors"
93102
task :rubocop_fix do
94-
sh "bundle exec rubocop -A"
103+
bundle_exec("rubocop -A")
95104
end
96105

97106
desc "Check buildable and its contents"
98107
task :build_test do
99-
sh "bundle exec rake build"
108+
bundle_exec("rake build")
100109
sh "tar -xvf pkg/line-bot-api-*.gem"
101110

102111
puts "<<Show the contents of the gem>>"

0 commit comments

Comments
 (0)