From 70ca4e413704b0125986df8213255f103567683a Mon Sep 17 00:00:00 2001 From: azjezz Date: Mon, 20 May 2024 17:50:53 +0100 Subject: [PATCH] chore: treat directories in configuration as nodes Signed-off-by: azjezz --- src/Indexer/Indexer.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Indexer/Indexer.php b/src/Indexer/Indexer.php index 5cbb08c..d055236 100644 --- a/src/Indexer/Indexer.php +++ b/src/Indexer/Indexer.php @@ -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; @@ -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) {