Module: ImageOptimizer::Shell::ClassMethods
- Defined in:
- lib/image_optimizer/shell.rb
Instance Method Summary collapse
- #run_command(command) ⇒ Object
-
#which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH.
Instance Method Details
#run_command(command) ⇒ Object
30 31 32 |
# File 'lib/image_optimizer/shell.rb', line 30 def run_command(command) `#{command}` end |
#which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/image_optimizer/shell.rb', line 19 def 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 end end nil end |