Class: RepoMgr::Tools

Inherits:
Object
  • Object
show all
Defined in:
lib/repo_mgr/tools.rb

Overview

Holds various tools

Class Method Summary collapse

Class Method Details

.error(msg) ⇒ Object



21
22
23
24
# File 'lib/repo_mgr/tools.rb', line 21

def self.error(msg)
  warn "-- Error: #{msg}".red
  Kernel.exit 1
end

.which(cmd) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/repo_mgr/tools.rb', line 8

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

  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