Skip to content

Commit 9cbbadc

Browse files
committed
jt: use the ruby that runs jt to run rubocop
* The ruby that runs jt can be set via $SYSTEM_RUBY when using bin/jt. * You will need to copy the git hook again so the hook uses bin/jt.
1 parent 7824b2d commit 9cbbadc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tool/jt.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,15 +2303,18 @@ def rubocop(*args)
23032303
args += RUBOCOP_INCLUDE_LIST
23042304
end
23052305

2306+
ruby = RbConfig.ruby
2307+
23062308
if gem_test_pack?
23072309
gem_home = "#{gem_test_pack}/rubocop-gems"
23082310
env = { 'GEM_HOME' => gem_home, 'GEM_PATH' => gem_home }
2309-
sh env, 'ruby', "#{gem_home}/bin/rubocop", *args
2311+
sh env, ruby, "#{gem_home}/bin/rubocop", *args
23102312
else
2311-
unless sh('rubocop', "_#{RUBOCOP_VERSION}_", *args, continue_on_failure: true)
2312-
sh 'gem', 'install', 'rubocop', '-v', RUBOCOP_VERSION
2313-
sh 'rubocop', "_#{RUBOCOP_VERSION}_", *args
2313+
env = { 'PATH' => "#{File.dirname(ruby)}:#{ENV['PATH']}" }
2314+
if Gem::Specification.find_all_by_name('rubocop', "#{RUBOCOP_VERSION}").empty?
2315+
sh env, 'gem', 'install', 'rubocop', '-v', RUBOCOP_VERSION
23142316
end
2317+
sh env, 'rubocop', "_#{RUBOCOP_VERSION}_", *args
23152318
end
23162319
end
23172320

0 commit comments

Comments
 (0)