Skip to content

Commit

Permalink
Handle unused extensions in dedicated method
Browse files Browse the repository at this point in the history
  • Loading branch information
t-geindre committed Jun 25, 2018
1 parent 892ec5f commit b5876b6
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Console/Deployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,7 @@ private function generateArchive(SymfonyStyle $io, ProgressBar $progress) : void
$projectConfig['php']['extensions'] ?? []
);
// Remove unused extensions
foreach (glob('.bref/output/.bref/bin/ext/*.so') as $extensionFile) {
if ($extensionFile === '.bref/output/.bref/bin/ext/opcache.so') {
continue;
}
$extensionName = substr($extensionFile, strrpos($extensionFile, '/') + 1, -3);
if (!array_key_exists($extensionName, $phpConfig)) {
$this->fs->remove($extensionFile);
}
}
$this->removeUnusedExtensions($phpConfig);
$progress->advance();

$progress->setMessage('Installing Bref files for NodeJS');
Expand Down Expand Up @@ -282,4 +274,16 @@ private function buildPhpConfig(string $sourceFile, string $targetFile, array $f

return $config;
}

private function removeUnusedExtensions(array $phpConfig)
{
foreach (glob('.bref/output/.bref/bin/ext/*.so') as $extensionFile) {
if ($extensionFile === '.bref/output/.bref/bin/ext/opcache.so') {
continue;
}
if (!array_key_exists(basename($extensionFile, '.so'), $phpConfig)) {
$this->fs->remove($extensionFile);
}
}
}
}

0 comments on commit b5876b6

Please sign in to comment.