Sha256: c6798219aa3f30f029dabe62fe0be3a83bfff8085013001578567a63bf92eb2c
Contents?: true
Size: 664 Bytes
Versions: 1
Compression:
Stored size: 664 Bytes
Contents
# Adapted from https://github.com/ruby/open3/blob/master/test/lib/find_executable.rb # frozen_string_literal: true require "rbconfig" module EnvUtil def find_executable(cmd, *args) exts = RbConfig::CONFIG["EXECUTABLE_EXTS"].split | [RbConfig::CONFIG["EXEEXT"]] ENV["PATH"].split(File::PATH_SEPARATOR).each do |path| next if path.empty? path = File.join(path, cmd) exts.each do |ext| cmdline = [path + ext, *args] begin return cmdline if yield(IO.popen(cmdline, "r", err: [:child, :out], &:read)) rescue next end end end nil end module_function :find_executable end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polyphony-1.6 | test/open3/find_executable.rb |