Skip to content

Commit

Permalink
bug #794 Skip doing anything on "install" (nicolas-grekas)
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
fabpot committed Sep 6, 2021
2 parents 7c9aef4 + 2396bdc commit f16f107
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Flex.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function install(Event $event)
}

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

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

if (!$recipes) {
if (null !== $event && ScriptEvents::POST_UPDATE_CMD === $event->getName()) {
if (ScriptEvents::POST_UPDATE_CMD === $event->getName()) {
$this->synchronizePackageJson($rootDir);
$this->lock->write();
}
$this->lock->write();

if ($this->downloader->isEnabled()) {
$this->io->writeError('Run <comment>composer recipes</> at any time to see the status of your Symfony recipes.');
Expand Down
6 changes: 5 additions & 1 deletion tests/FlexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Composer\Repository\RepositoryManager;
use Composer\Repository\WritableRepositoryInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use Composer\Semver\Constraint\MatchAllConstraint;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -306,7 +307,10 @@ private function mockLock(): Lock

private function mockFlexEvent(): Event
{
return $this->getMockBuilder(Event::class)->disableOriginalConstructor()->getMock();
$event = $this->getMockBuilder(Event::class)->disableOriginalConstructor()->getMock();
$event->expects($this->any())->method('getName')->willReturn(ScriptEvents::POST_UPDATE_CMD);

return $event;
}

private function mockManager(): RepositoryManager
Expand Down

0 comments on commit f16f107

Please sign in to comment.