Skip to content

Commit f16f107

Browse files
committed
bug #794 Skip doing anything on "install" (nicolas-grekas)
This PR was merged into the 1.13-dev branch. Discussion ---------- Skip doing anything on "install" Fix #669 Commits ------- 2396bdc Skip doing anything on "install"
2 parents 7c9aef4 + 2396bdc commit f16f107

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Flex.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public function install(Event $event)
407407
}
408408

409409
// Execute missing recipes
410-
$recipes = $this->fetchRecipes($this->operations);
410+
$recipes = ScriptEvents::POST_UPDATE_CMD === $event->getName() ? $this->fetchRecipes($this->operations) : [];
411411
$this->operations = []; // Reset the operation after getting recipes
412412

413413
if (2 === $this->displayThanksReminder) {
@@ -422,10 +422,10 @@ public function install(Event $event)
422422
$this->io->writeError('');
423423

424424
if (!$recipes) {
425-
if (null !== $event && ScriptEvents::POST_UPDATE_CMD === $event->getName()) {
425+
if (ScriptEvents::POST_UPDATE_CMD === $event->getName()) {
426426
$this->synchronizePackageJson($rootDir);
427+
$this->lock->write();
427428
}
428-
$this->lock->write();
429429

430430
if ($this->downloader->isEnabled()) {
431431
$this->io->writeError('Run <comment>composer recipes</> at any time to see the status of your Symfony recipes.');

tests/FlexTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Composer\Repository\RepositoryManager;
2626
use Composer\Repository\WritableRepositoryInterface;
2727
use Composer\Script\Event;
28+
use Composer\Script\ScriptEvents;
2829
use Composer\Semver\Constraint\MatchAllConstraint;
2930
use PHPUnit\Framework\TestCase;
3031
use Symfony\Component\Console\Output\OutputInterface;
@@ -306,7 +307,10 @@ private function mockLock(): Lock
306307

307308
private function mockFlexEvent(): Event
308309
{
309-
return $this->getMockBuilder(Event::class)->disableOriginalConstructor()->getMock();
310+
$event = $this->getMockBuilder(Event::class)->disableOriginalConstructor()->getMock();
311+
$event->expects($this->any())->method('getName')->willReturn(ScriptEvents::POST_UPDATE_CMD);
312+
313+
return $event;
310314
}
311315

312316
private function mockManager(): RepositoryManager

0 commit comments

Comments
 (0)