lib/iblinter/iblinter.rb in danger-iblinter-0.0.4 vs lib/iblinter/iblinter.rb in danger-iblinter-0.0.5
- old
+ new
@@ -1,10 +1,11 @@
# frozen_string_literal: true
class IBLinterRunner
- def initialize(binary_path)
+ def initialize(binary_path, execute_command)
@binary_path = binary_path
+ @execute_command = execute_command
end
def run(command)
`#{command}`
end
@@ -14,11 +15,12 @@
Dir.chdir path
JSON.parse(run(command))
end
def lint_command(options)
- abs_binary_path = @binary_path.nil? ? "iblinter" : File.absolute_path(@binary_path)
- "#{abs_binary_path} lint #{arguments(options.merge(reporter: 'json'))}"
+ executable = @execute_command
+ executable ||= @binary_path.nil? ? "iblinter" : File.absolute_path(@binary_path)
+ "#{executable} lint #{arguments(options.merge(reporter: 'json'))}"
end
# Parse options into shell arguments.
# Reference https://github.com/ashfurrow/danger-ruby-swiftlint/blob/0af6d5aff38dc666352ea3750266fb7630d88bdd/ext/swiftlint/swiftlint.rb#L38
def arguments(options)