mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-08-28 23:26:18 +02:00
respect windows
This commit is contained in:
parent
d24e2943ca
commit
7d6992c0e8
@ -21,3 +21,4 @@ end
|
||||
|
||||
# Executable generation and encoding
|
||||
require 'msf/util/exe'
|
||||
require 'msf/util/helper'
|
||||
|
19
lib/msf/util/helper.rb
Normal file
19
lib/msf/util/helper.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: binary -*-
|
||||
|
||||
module Msf
|
||||
module Util
|
||||
class Helper
|
||||
# Cross-platform way of finding an executable in the $PATH.
|
||||
#
|
||||
# which('ruby') #=> /usr/bin/ruby
|
||||
def self.which(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
|
||||
end
|
@ -25,8 +25,7 @@ Gem::Specification.new do |spec|
|
||||
spec.license = 'BSD-3-clause'
|
||||
|
||||
# only do a git ls-files if the .git folder exists and we have a git binary in PATH
|
||||
if File.directory?(File.join(File.dirname(__FILE__), ".git")) &&
|
||||
ENV['PATH'].split(':').collect {|d| Dir.entries d if Dir.exists? d}.flatten.include?("git")
|
||||
if File.directory?(File.join(File.dirname(__FILE__), ".git")) && Msf::Util::Helper.which("git")
|
||||
spec.files = `git ls-files`.split($/).reject { |file|
|
||||
file =~ /^documentation|^external/
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user