Fix for windows

This commit is contained in:
Nemo 2017-11-13 02:46:21 +05:30
parent 8c0e17d58d
commit 4cb0b76d2f
1 changed files with 9 additions and 5 deletions

View File

@ -17,11 +17,15 @@ module Nokogiri
end
# https://stackoverflow.com/a/42533209/368328
def command?(name)
[name,
*ENV['PATH'].split(File::PATH_SEPARATOR)
.map { |p| File.join(p, name) }]
.find { |f| File.executable?(f) }
def command?(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each { |ext|
exe = File.join(path, "#{cmd}#{ext}")
return exe if File.executable?(exe) && !File.directory?(exe)
}
end
return nil
end
def commands?(commands)