Skip to content

Commit

Permalink
Fix regression re: incorrect glob pattern for folders (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodywasishere authored Jan 25, 2025
1 parent db2d6c6 commit 728d0e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions spec/ameba/glob_utils_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ module Ameba
.should_not contain current_file_path
end

it "doesn't return rejected folders" do
subject
.find_files_by_globs(["**/*_spec.cr", "!spec"])
.should be_empty
end

it "doesn't return duplicated globs" do
subject
.find_files_by_globs(["**/*_spec.cr", "**/*_spec.cr"])
Expand All @@ -47,6 +53,10 @@ module Ameba
fail "#{path.inspect} should be a file" unless File.file?(path)
end
end

it "expands folders" do
subject.expand(["spec"]).should_not be_empty
end
end
end
end
6 changes: 4 additions & 2 deletions src/ameba/glob_utils.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ module Ameba
globs
.flat_map do |glob|
if File.directory?(glob)
glob += "/**/*.cr"
ext = ".cr"

Ameba.ecr_supported? do
glob += "/**/*.ecr"
ext = ".{cr,ecr}"
end

glob += "/**/*#{ext}"
end

Dir[glob]
Expand Down

0 comments on commit 728d0e9

Please sign in to comment.