Method: FastlaneCore::CommandExecutor.which
- Defined in:
- fastlane_core/lib/fastlane_core/command_executor.rb
.which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH. Respects the $PATHEXT, which lists valid file extensions for executables on Windows.
which('ruby') #=> /usr/bin/ruby
Derived from stackoverflow.com/a/5471032/3005
15 16 17 18 19 20 21 22 23 |
# File 'fastlane_core/lib/fastlane_core/command_executor.rb', line 15 def which(cmd) ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| cmd_path = File.join(path, cmd) executable_path = Helper.get_executable_path(cmd_path) return executable_path if Helper.executable?(executable_path) end return nil end |