Method: Watchful::Action.have_command?

Defined in:
lib/watchful/action.rb

.have_command?(cmd) ⇒ Boolean

todo: better have_command?

Returns:

  • (Boolean)


56
57
58
59
60
61
62
63
64
# File 'lib/watchful/action.rb', line 56

def Action.have_command?(cmd)
	raise 'Argument must be a string' if not cmd.kind_of? String
	raise 'Argument cannot be an empty string' if cmd.empty?
	
	ENV['PATH'].split(':').each do |dir|
		return true if File.exists?("#{dir}/#{cmd}")
	end
	false
end