This repository was archived by the owner on Jul 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,10 @@ def initialize(engine_config:, patterns:)
13
13
14
14
def files
15
15
engine_config . include_paths . flat_map do |path |
16
- if path . end_with? ( "/" )
16
+ pathname = Pathname . new ( path )
17
+ if pathname . directory? && !pathname . cleanpath . symlink?
17
18
expand ( path )
18
- elsif matches? ( path )
19
+ elsif pathname . file? && ! pathname . symlink? && matches? ( path )
19
20
[ path ]
20
21
else
21
22
[ ]
@@ -30,11 +31,11 @@ def files
30
31
def expand ( path )
31
32
globs = patterns . map { |p | File . join ( relativize ( path ) , p ) }
32
33
33
- Dir . glob ( globs ) . select { |f | File . file? ( f ) }
34
+ Dir . glob ( globs ) . select { |f | File . file? ( f ) && ! File . symlink? ( f ) }
34
35
end
35
36
36
37
def matches? ( path )
37
- File . file? ( path ) && patterns . any? do |p |
38
+ patterns . any? do |p |
38
39
File . fnmatch? (
39
40
relativize ( p ) ,
40
41
relativize ( path ) ,
Original file line number Diff line number Diff line change 15
15
File . write ( File . join ( @tmp_dir , "foo.jsx" ) , "" )
16
16
File . write ( File . join ( @tmp_dir , "foo.ex" ) , "" )
17
17
18
- example . run
18
+ File . write ( "/tmp/bar.js" , "" )
19
+ FileUtils . ln_s ( "/tmp/bar.js" , File . join ( @tmp_dir , "bar.js" ) )
20
+ Dir . mkdir ( "/tmp/baz" )
21
+ File . write ( "/tmp/baz/baz.js" , "" )
22
+ FileUtils . ln_s ( "/tmp/baz/" , File . join ( @tmp_dir , "baz" ) )
23
+
24
+ begin
25
+ example . run
26
+ ensure
27
+ FileUtils . rm_rf ( [ "/tmp/bar.js" , "/tmp/baz" ] )
28
+ end
19
29
end
20
30
end
21
31
end
22
32
23
33
describe "#files" do
24
- it "expands patterns for directory includes" do
34
+ it "expands patterns for directory includes, and ignores symlinks " do
25
35
file_list = ::CC ::Engine ::Analyzers ::FileList . new (
26
36
engine_config : CC ::Engine ::Analyzers ::EngineConfig . new (
27
37
"include_paths" => [ "./" ] ,
You can’t perform that action at this time.
0 commit comments