class Aruba::Platforms::WindowsWhich

@private
Implement ‘which(command)` for windows

def call(program, path = ENV["PATH"])

Parameters:
  • path (String) --
  • program (String) --
def call(program, path = ENV["PATH"])
  raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
  program = program.to_s
  program += windows_executable_extentions if File.extname(program).empty?
  whiches.find { |w| w.match? program }.new.call(program, path)
end

def initialize

def initialize
  @whiches = []
  @whiches << AbsoluteOrRelativePathWhich
  @whiches << ProgramWhich
  @whiches << DefaultWhich
end

def windows_executable_extentions

def windows_executable_extentions
  if ENV["PATHEXT"]
    format(".{%s}", ENV["PATHEXT"].tr(";", ",").tr(".", "")).downcase
  else
    ".{exe,com,bat}"
  end
end