Repository: soutaro/steep (Ruby)

Issue:
Wildcards in `check` directive do not expand in Steepfile
Using wildcards in the `check` directive of the Steepfile does not expand the files as expected.

### Steps to Reproduce
1. Create a `Steepfile` with the following content:
    ```ruby
    target :app do
      signature 'sig'

      check 'app'
      check 'packs/*/app'
    end
    ```
2. Run the command `steep project` from the command line.

### Expected Behavior
When executing the `steep project` command, all files matching `packs/*/app` are expected to be listed under `files`.

### Actual Behavior
No files matching `packs/*/app` are displayed.

### Environment Information
- Ruby version: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [aarch64-linux]
- Steep version: 1.6.0



Discussion:

Patch:
diff --git a/lib/steep/services/file_loader.rb b/lib/steep/services/file_loader.rb
index 93605e1b4..ebfcbbcac 100644
--- a/lib/steep/services/file_loader.rb
+++ b/lib/steep/services/file_loader.rb
@@ -12,30 +12,25 @@ def each_path_in_patterns(pattern, commandline_patterns = [])
           pats = commandline_patterns.empty? ? pattern.patterns : commandline_patterns
 
           pats.each do |path|
-            absolute_path = base_dir + path
-
-            if absolute_path.file?
-              relative_path = absolute_path.relative_path_from(base_dir)
-              if pattern =~ relative_path
-                yield relative_path
-              end
-            else
-              files = if absolute_path.directory?
-                        Pathname.glob("#{absolute_path}/**/*#{pattern.ext}")
-                      else
-                        Pathname.glob(absolute_path.to_s)
-                      end
-
-              files.sort.each do |source_path|
-                if source_path.file?
-                  relative_path = source_path.relative_path_from(base_dir)
-                  unless pattern.ignore?(relative_path)
-                    yield relative_path
+            Pathname.glob((base_dir + path).to_s).each do |absolute_path|
+              if absolute_path.file?
+                relative_path = absolute_path.relative_path_from(base_dir)
+                if pattern =~ relative_path
+                  yield relative_path
+                end
+              else
+                files = Pathname.glob("#{absolute_path}/**/*#{pattern.ext}")
+
+                files.sort.each do |source_path|
+                  if source_path.file?
+                    relative_path = source_path.relative_path_from(base_dir)
+                    unless pattern.ignore?(relative_path)
+                      yield relative_path
+                    end
                   end
                 end
               end
             end
-
           end
         else
           enum_for :each_path_in_patterns, pattern, commandline_patterns


Test patch:
diff --git a/test/file_loader_test.rb b/test/file_loader_test.rb
index f5bdc0439..69c552c8c 100644
--- a/test/file_loader_test.rb
+++ b/test/file_loader_test.rb
@@ -33,4 +33,34 @@ def test_each_path_in_patterns
       assert_empty loader.each_path_in_patterns(pat, ["Rakefile"]).to_a
     end
   end
+
+  def test_each_path_in_patterns_with_glob
+    in_tmpdir do
+      loader = FileLoader.new(base_dir: current_dir)
+
+      (current_dir + "lib/foo/bar").mkpath()
+      (current_dir + "lib/foo/bar/baz.rb").write("")
+      (current_dir + "lib/foo/parser.rb").write("")
+      (current_dir + "lib/foo/bar/index.html.erb").write("")
+
+      pat = Pattern.new(patterns: ["lib/*/bar"], ext: ".rb")
+
+      assert_equal [Pathname("lib/foo/bar/baz.rb")], loader.each_path_in_patterns(pat, []).to_a
+    end
+  end
+
+  def test_each_path_in_patterns_with_glob_and_ext
+    in_tmpdir do
+      loader = FileLoader.new(base_dir: current_dir)
+
+      (current_dir + "lib/foo/bar").mkpath()
+      (current_dir + "lib/foo/bar/baz.rb").write("")
+      (current_dir + "lib/foo/parser.rb").write("")
+      (current_dir + "lib/foo/bar/index.html.erb").write("")
+
+      pat = Pattern.new(patterns: ["lib/*/bar/baz.rb"], ext: ".rb")
+
+      assert_equal [Pathname("lib/foo/bar/baz.rb")], loader.each_path_in_patterns(pat, []).to_a
+    end
+  end
 end