Skip to content

Commit 32a2013

Browse files
committed
add method reinstallDevPackages()
1 parent 5f1045c commit 32a2013

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

system/Commands/Utilities/Optimize.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ public function run(array $params)
8383
try {
8484
$this->runCaching($enableConfigCache, $enableLocatorCache, $disable);
8585
$this->clearCache();
86-
$this->removeDevPackages();
86+
if($disable === true) {
87+
$this->reinstallDevPackages();
88+
} else {
89+
$this->removeDevPackages();
90+
}
8791
} catch (RuntimeException) {
8892
CLI::error('The "spark optimize" failed.');
8993

@@ -230,4 +234,24 @@ private function removeDevPackages(): void
230234

231235
throw new RuntimeException(__METHOD__);
232236
}
237+
238+
private function reinstallDevPackages(): void
239+
{
240+
if (! defined('VENDORPATH')) {
241+
return;
242+
}
243+
244+
chdir(ROOTPATH);
245+
passthru('composer install', $status);
246+
247+
if ($status === 0) {
248+
CLI::write('Installed Composer dev packages.', 'green');
249+
250+
return;
251+
}
252+
253+
CLI::error('Error in installing Composer dev packages.');
254+
255+
throw new RuntimeException(__METHOD__);
256+
}
233257
}

0 commit comments

Comments
 (0)