From 728d0e98ecddc7b51e82713979eacbea36495c7e Mon Sep 17 00:00:00 2001 From: Margret Riegert Date: Sat, 25 Jan 2025 06:30:50 -0500 Subject: [PATCH] Fix regression re: incorrect glob pattern for folders (#546) --- spec/ameba/glob_utils_spec.cr | 10 ++++++++++ src/ameba/glob_utils.cr | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/ameba/glob_utils_spec.cr b/spec/ameba/glob_utils_spec.cr index 153b7909f..2cc5f51ae 100644 --- a/spec/ameba/glob_utils_spec.cr +++ b/spec/ameba/glob_utils_spec.cr @@ -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"]) @@ -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 diff --git a/src/ameba/glob_utils.cr b/src/ameba/glob_utils.cr index cee311b46..d74304436 100644 --- a/src/ameba/glob_utils.cr +++ b/src/ameba/glob_utils.cr @@ -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]