Method: PDK::Validate::ExternalCommandValidator#invoke

Defined in:
lib/pdk/validate/external_command_validator.rb

#invoke(report) ⇒ Object

Invokes the prepared commands as an ExecGroup

See Also:

  • Validator.invoke


173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/pdk/validate/external_command_validator.rb', line 173

def invoke(report)
  prepare_invoke!

  process_skipped(report, @skipped)
  process_invalid(report, @invalid)

  # Nothing to execute so return success
  return 0 if @commands.empty?

  # If there's no Gemfile, then we can't ensure the binstubs are correct
  PDK::Util::Bundler.ensure_binstubs!(cmd) unless PDK::Util::Bundler::BundleHelper.new.gemfile.nil?

  exec_group = PDK::CLI::ExecGroup.create(name, { parallel: false }, options)

  # Register all of the commands for all of the targets
  @commands.each do |item|
    command = item[:command]
    invokation_targets = item[:invokation_targets]

    exec_group.register do
      result = command.execute!
      begin
        parse_output(report, result, invokation_targets.compact)
      rescue PDK::Validate::ParseOutputError => e
        $stderr.puts e.message
      end
      result[:exit_code]
    end
  end

  # Now execute and get the return code
  exec_group.exit_code
end