File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,4 @@ module Util
21
21
22
22
# Executable generation and encoding
23
23
require 'msf/util/exe'
24
+ require 'msf/util/helper'
Original file line number Diff line number Diff line change
1
+ # -*- coding: binary -*-
2
+
3
+ module Msf
4
+ module Util
5
+ class Helper
6
+ # Cross-platform way of finding an executable in the $PATH.
7
+ #
8
+ # which('ruby') #=> /usr/bin/ruby
9
+ def self . which ( cmd )
10
+ exts = ENV [ 'PATHEXT' ] ? ENV [ 'PATHEXT' ] . split ( ';' ) : [ '' ]
11
+ ENV [ 'PATH' ] . split ( File ::PATH_SEPARATOR ) . each do |path |
12
+ exts . each { |ext |
13
+ exe = File . join ( path , "#{ cmd } #{ ext } " )
14
+ return exe if File . executable? ( exe ) && !File . directory? ( exe )
15
+ }
16
+ end
17
+ return nil
18
+ end
19
+ end
Original file line number Diff line number Diff line change @@ -25,8 +25,7 @@ Gem::Specification.new do |spec|
25
25
spec . license = 'BSD-3-clause'
26
26
27
27
# only do a git ls-files if the .git folder exists and we have a git binary in PATH
28
- if File . directory? ( File . join ( File . dirname ( __FILE__ ) , ".git" ) ) &&
29
- ENV [ 'PATH' ] . split ( ':' ) . collect { |d | Dir . entries d if Dir . exists? d } . flatten . include? ( "git" )
28
+ if File . directory? ( File . join ( File . dirname ( __FILE__ ) , ".git" ) ) && Msf ::Util ::Helper . which ( "git" )
30
29
spec . files = `git ls-files` . split ( $/) . reject { |file |
31
30
file =~ /^documentation|^external/
32
31
}
You can’t perform that action at this time.
0 commit comments