Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
fill-index : treat index.php at root + in dot directories (but vcs dir)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebSept committed May 22, 2021
1 parent c125771 commit 0f66226
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Command/SebSept/IndexPhpFiller.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ private function addMissingIndexFiles(): void
foreach ($this->getDirectoryIterator() as $fileInfo) {
$this->addIndex($fileInfo);
}
// also at the root - I haven't found a way to include it in the iterator :/
$this->addIndex(new \SplFileInfo($this->getcwd()));
}

private function addIndex(\SplFileInfo $splFileInfo): void
Expand All @@ -107,6 +109,8 @@ private function checkMissingIndexes(): int
$indexPhpPath = $fileInfo->getPathname() . '/index.php';
$this->fs->exists($indexPhpPath) ?: array_push($missingIndexFiles, $indexPhpPath);
}
// plus index.php at root
$this->fs->exists($this->getcwd() . '/index.php') ?: array_push($missingIndexFiles, './index.php');

if (empty($missingIndexFiles)) {
$this->getIO()->write('Good : no missing index files.');
Expand Down Expand Up @@ -148,6 +152,8 @@ private function getDirectoryIterator()
return (new Finder())
->in($this->getcwd())
->directories()
->ignoreDotFiles(false)
->ignoreVCS(true)
->exclude('vendor')
->getIterator();
}
Expand Down

0 comments on commit 0f66226

Please sign in to comment.