Skip to content

Commit

Permalink
Use correct lizard command when custom executable is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrebenets committed Apr 5, 2018
1 parent d108a9d commit ea926e8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/fastlane/plugin/lizard/actions/lizard_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ def self.run(params)
UI.user_error!("The custom executable at '#{params[:executable]}' does not exist.")
end

lizard_cli_version = Gem::Version.new(`lizard --version`.scan(/(?:\d+\.?){3}/).first)
lizard_command = "python #{params[:executable]}" || "lizard"

lizard_cli_version = Gem::Version.new(`#{lizard_command} --version`.scan(/(?:\d+\.?){3}/).first)
required_version = Gem::Version.new(Fastlane::Lizard::CLI_VERSION)
if lizard_cli_version < required_version
UI.user_error!("Your lizard version is outdated, please upgrade to at least version #{Fastlane::Lizard::CLI_VERSION} and start your lane again!")
Expand All @@ -19,7 +21,7 @@ def self.run(params)
command = forming_command(params)

if params[:show_warnings]
Fastlane::Actions.sh_control_output("lizard #{params[:source_folder]} | sed -n -e '/^$/,$p'", print_command: true, print_command_output: true)
Fastlane::Actions.sh_control_output("#{lizard_command} #{params[:source_folder]} | sed -n -e '/^$/,$p'", print_command: true, print_command_output: true)
end

begin
Expand All @@ -32,8 +34,7 @@ def self.run(params)

def self.forming_command(params)
command = []
command << 'lizard' unless params[:executable]
command << "python #{params[:executable]}" if params[:executable]
command << lizard_command
command << params[:language].split(",").map { |l| "-l #{l.strip}" }.join(" ") if params[:language]
command << "--#{params[:export_type]}" if params[:export_type]
command << "-C #{params[:ccn]}" if params[:ccn] # stands for cyclomatic complexity number
Expand Down

0 comments on commit ea926e8

Please sign in to comment.