Skip to content

Commit

Permalink
chore: treat directories in configuration as nodes
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed May 20, 2024
1 parent c332fc6 commit 70ca4e4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Indexer/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ public function index(Configuration $configuration): Index
$index = new Index([]);

foreach ($directories as $directory) {
$index = $index->merge(
$this->indexDirectory($directory, $configuration),
);
if ($this->filesystem->isDirectory($directory)) {
$index = $index->merge($this->indexDirectory($directory, $configuration));
} else {
$node = $this->getNode($directory, $configuration);
if ($node !== null) {
$index = $index->withNode($node);
}
}
}

return $index;
Expand All @@ -50,10 +55,6 @@ public function index(Configuration $configuration): Index
private function indexDirectory(string $directory, Configuration $configuration): Index
{
$index = new Index([]);
if (!$this->filesystem->isDirectory($directory)) {
return $index;
}

if ($configuration->watchDirectories) {
$node = $this->getNode($directory, $configuration);
if ($node === null) {
Expand Down

0 comments on commit 70ca4e4

Please sign in to comment.