Top Level Namespace

Defined Under Namespace

Modules: Transmuter

Constant Summary collapse

ROOT_PATH =
File.expand_path(File.join(File.dirname(__FILE__), '..'))

Instance Method Summary collapse

Instance Method Details

#which(cmd) ⇒ Object

Taken from hub github.com/defunkt/hub/blob/master/lib/hub/context.rb#L186 Cross-platform way of finding an executable in the $PATH.

which(‘ruby’) #=> /usr/bin/ruby



8
9
10
11
12
13
14
15
16
17
# File 'lib/transmuter.rb', line 8

def which(cmd)
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
    exts.each { |ext|
      exe = "#{path}/#{cmd}#{ext}"
      return exe if File.executable? exe
    }
  end
  return nil
end