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

Commit 7adb615

Browse files
authored
Merge pull request #30 from SebSept/improve_index_filler
-index.php at root is taken into account, was not treated before. - fix & improve messages
2 parents 34f5a88 + 0f66226 commit 7adb615

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/Command/SebSept/IndexPhpFiller.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ private function addMissingIndexFiles(): void
8989
foreach ($this->getDirectoryIterator() as $fileInfo) {
9090
$this->addIndex($fileInfo);
9191
}
92+
// also at the root - I haven't found a way to include it in the iterator :/
93+
$this->addIndex(new \SplFileInfo($this->getcwd()));
9294
}
9395

9496
private function addIndex(\SplFileInfo $splFileInfo): void
@@ -107,16 +109,22 @@ private function checkMissingIndexes(): int
107109
$indexPhpPath = $fileInfo->getPathname() . '/index.php';
108110
$this->fs->exists($indexPhpPath) ?: array_push($missingIndexFiles, $indexPhpPath);
109111
}
112+
// plus index.php at root
113+
$this->fs->exists($this->getcwd() . '/index.php') ?: array_push($missingIndexFiles, './index.php');
110114

111115
if (empty($missingIndexFiles)) {
112116
$this->getIO()->write('Good : no missing index files.');
113117

114118
return 0;
115119
}
116120

117-
$this->getIO()->write(':( Missing index.php files.');
121+
$this->getIO()->write('<fg=red>✗ Missing index.php files.</>');
122+
$this->getIO()->write('Missing index.php : ', true, IOInterface::VERBOSE);
118123
$this->getIO()->write($missingIndexFiles, true, IOInterface::VERBOSE);
119-
$this->getIO()->write(['Use <info>-v</info> option to list missing files', 'Remove <info>--check-only</info> option to add missing files.']);
124+
$this->getIO()->write([
125+
sprintf('Run <info>composer psdt:%s --check-only -v</info> option to list missing files', $this->getName()),
126+
sprintf('Or run <info>composer psdt:%s</info> to add missing files.', $this->getName()),
127+
]);
120128

121129
return 1;
122130
}
@@ -144,6 +152,8 @@ private function getDirectoryIterator()
144152
return (new Finder())
145153
->in($this->getcwd())
146154
->directories()
155+
->ignoreDotFiles(false)
156+
->ignoreVCS(true)
147157
->exclude('vendor')
148158
->getIterator();
149159
}

0 commit comments

Comments
 (0)