Class: Hirb::Util
- Inherits:
-
Object
- Object
- Hirb::Util
- Defined in:
- lib/spirit_hands/hirb/fixes/util.rb
Class Method Summary collapse
-
.command_exists?(command) ⇒ Boolean
Determines if a shell command exists by searching for it in ENV.
Class Method Details
.command_exists?(command) ⇒ Boolean
Determines if a shell command exists by searching for it in ENV. (Fixed version)
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/spirit_hands/hirb/fixes/util.rb', line 7 def command_exists?(command) if c = Pathname.new(command) return true if c.absolute? && c.exist? end executable_file_exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).any? do |d| executable_file_exts.any? do |ext| f = File.(command + ext, d) File.executable?(f) && !File.directory?(f) end end end |