Module: Teaspoon::Utility

Included in:
Drivers::PhantomjsDriver, Exporter, Instrumentation
Defined in:
lib/teaspoon/utility.rb

Instance Method Summary collapse

Instance Method Details

#which(cmd) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/teaspoon/utility.rb', line 7

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.executable?(exe)
    end
  end

  nil
end