Skip to content

Commit

Permalink
Fix the list of supported shells for completions in a phar
Browse files Browse the repository at this point in the history
Using glob inside a phar does not work (it does not find anything).
Using a DirectoryIterator on the other hand works with phars. This
allows this command to compute the list of supported shells properly
when used inside a phar.
  • Loading branch information
stof committed Apr 21, 2023
1 parent 9f16d3e commit 930de43
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Command/DumpCompletionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,14 @@ private function tailDebugLog(string $commandName, OutputInterface $output): voi
*/
private function getSupportedShells(): array
{
return array_map(function ($f) {
return pathinfo($f, \PATHINFO_EXTENSION);
}, glob(__DIR__.'/../Resources/completion.*'));
$shells = [];

foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file) {
if (str_starts_with($file->getBasename(), 'completion.') && $file->isFile()) {
$shells[] = $file->getExtension();
}
}

return $shells;
}
}

0 comments on commit 930de43

Please sign in to comment.