lib/pdk/validate/external_command_validator.rb in pdk-2.7.1 vs lib/pdk/validate/external_command_validator.rb in pdk-3.0.0
- old
+ new
@@ -74,28 +74,31 @@
def alternate_bin_paths
[
PDK::Util::RubyVersion.bin_path,
File.join(PDK::Util::RubyVersion.gem_home, 'bin'),
PDK::Util::RubyVersion.gem_paths_raw.map { |gem_path_raw| File.join(gem_path_raw, 'bin') },
- PDK::Util.package_install? ? File.join(PDK::Util.pdk_package_basedir, 'bin') : nil,
+ PDK::Util.package_install? ? File.join(PDK::Util.pdk_package_basedir, 'bin') : nil
].flatten.compact
end
# The full path to the command (cmd)
# Can be overridden in child classes to a non-default path
# @return [String]
# @api private
def cmd_path
return @cmd_path unless @cmd_path.nil?
+
@cmd_path = File.join(context.root_path, 'bin', cmd)
# Return the path to the command if it exists on disk, or we have a gemfile (i.e. Bundled install)
# The Bundle may be created after the prepare_invoke so if the file doesn't exist, it may not be an error
return @cmd_path if PDK::Util::Filesystem.exist?(@cmd_path) || !PDK::Util::Bundler::BundleHelper.new.gemfile.nil?
+
# But if there is no Gemfile AND cmd doesn't exist in the default path, we need to go searching...
@cmd_path = alternate_bin_paths.map { |alternate_path| File.join(alternate_path, cmd) }
.find { |path| PDK::Util::Filesystem.exist?(path) }
return @cmd_path unless @cmd_path.nil?
+
# If we can't find it anywhere, just let the OS find it
@cmd_path = cmd
end
# An array of command line arguments to pass to the command for validation
@@ -119,10 +122,11 @@
# Prepares for invokation by parsing targets and creating the needed commands.
# @api private
# @see PDK::Validate::Validator.prepare_invoke!
def prepare_invoke!
return if @prepared
+
super
@targets, @skipped, @invalid = parse_targets
@targets = [] if @targets.nil?
@@ -142,9 +146,10 @@
# Register all of the commands for all of the targets
@commands = []
target_groups.each do |invokation_targets|
next if invokation_targets.empty? && !allow_empty_targets?
+
cmd_argv = parse_options(invokation_targets).unshift(cmd_path).compact
cmd_argv.unshift(File.join(PDK::Util::RubyVersion.bin_path, 'ruby.exe'), '-W0') if Gem.win_platform?
command = PDK::CLI::Exec::Command.new(*cmd_argv).tap do |c|
c.context = :module