Module: Teaspoon::Utility

Included in:
Driver::Phantomjs, Exporter, Instrumentation
Defined in:
lib/teaspoon/utility.rb

Instance Method Summary collapse

Instance Method Details

#which(cmd) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/teaspoon/utility.rb', line 16

def which(cmd)
  exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]

  ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
    exts.each do |ext|
      exe = "#{path}/#{cmd}#{ext}"
      return exe if File.file?(exe) && File.executable?(exe)
    end
  end

  nil
end