Skip to content

Commit 26b6b2a

Browse files
authored
(fix) glob support for directory path expansion
paths without `*` follow the existing logic unchanged. Only glob-containing paths get expanded via `glob()`
1 parent d9b32b6 commit 26b6b2a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Support/FileFinder.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,24 @@ private static function separateDirectoriesAndFiles(array $paths): array
3939
if (! str_starts_with($path, DIRECTORY_SEPARATOR)) {
4040
$path = getcwd().DIRECTORY_SEPARATOR.$path;
4141
}
42+
43+
if (str_contains($path, '*')) {
44+
$expanded = glob($path, GLOB_ONLYDIR);
45+
if ($expanded !== false) {
46+
$dirs = [...$dirs, ...$expanded];
47+
}
48+
49+
continue;
50+
}
51+
4252
if (is_dir($path)) {
4353
$dirs[] = $path;
4454
} elseif (is_file($path)) {
4555
$file = new \SplFileInfo($path);
4656
$files[] = new SplFileInfo($file->getPathname(), $file->getPath(), $file->getFilename());
4757
}
4858
}
49-
59+
5060
return ['directories' => $dirs, 'files' => $files];
5161
}
5262

0 commit comments

Comments
 (0)