Module: Asciidoctor::Diagram::Which
- Defined in:
- lib/asciidoctor-diagram/util/which.rb
Class Method Summary collapse
Class Method Details
.which(cmd, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/asciidoctor-diagram/util/which.rb', line 5 def self.which(cmd, = {}) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] paths = ([:path] || []) + (ENV['PATH'] ? ENV['PATH'].split(File::PATH_SEPARATOR) : []) paths.each do |path| exts.each { |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable? exe } end nil end |