Module: Gelauto::CLIUtils

Extended by:
CLIUtils
Included in:
CLIUtils
Defined in:
lib/gelauto/cli_utils.rb

Constant Summary collapse

EXTS =
(ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']).freeze

Instance Method Summary collapse

Instance Method Details

#which(cmd) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/gelauto/cli_utils.rb', line 5

def which(cmd)
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
    EXTS.each do |ext|
      exe = File.join(path, "#{cmd}#{ext}")
      return exe if File.executable?(exe) && !File.directory?(exe)
    end
  end

  nil
end