Skip to content

Commit

Permalink
add method reinstallDevPackages()
Browse files Browse the repository at this point in the history
  • Loading branch information
warcooft committed Jul 30, 2024
1 parent 5f1045c commit 32a2013
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion system/Commands/Utilities/Optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ public function run(array $params)
try {
$this->runCaching($enableConfigCache, $enableLocatorCache, $disable);
$this->clearCache();
$this->removeDevPackages();
if($disable === true) {
$this->reinstallDevPackages();
} else {
$this->removeDevPackages();
}
} catch (RuntimeException) {
CLI::error('The "spark optimize" failed.');

Expand Down Expand Up @@ -230,4 +234,24 @@ private function removeDevPackages(): void

throw new RuntimeException(__METHOD__);
}

private function reinstallDevPackages(): void
{
if (! defined('VENDORPATH')) {
return;
}

chdir(ROOTPATH);
passthru('composer install', $status);

if ($status === 0) {
CLI::write('Installed Composer dev packages.', 'green');

return;
}

CLI::error('Error in installing Composer dev packages.');

throw new RuntimeException(__METHOD__);
}
}

0 comments on commit 32a2013

Please sign in to comment.