Skip to content

Commit

Permalink
Merge pull request #44 from edersoares/restart
Browse files Browse the repository at this point in the history
Restart factory to not show message twice
  • Loading branch information
edersoares authored Mar 28, 2023
2 parents dbfaf4a + 3eacdd4 commit ac1ded9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/Composer/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@

class Factory extends ComposerFactory implements PlugAndPlayInterface
{
private static bool $loaded = false;

/**
* Restart factory.
*/
public static function restart(): void
{
static::$loaded = false;
}

/**
* Loads Composer JSON file if it has a validated schema.
*
Expand Down Expand Up @@ -161,6 +171,10 @@ private function definePluggedAndIgnoredPackages(IOInterface $io, array &$plugge
*/
private function writePluggedAndIgnoredPackages(IOInterface $io, array $plugged, array $ignored): void
{
if (static::$loaded) {
return;
}

if ($plugged) {
sort($plugged);

Expand All @@ -180,5 +194,7 @@ private function writePluggedAndIgnoredPackages(IOInterface $io, array $plugged,
foreach ($ignored as $package) {
$io->write(" Ignored: $package");
}

static::$loaded = true;
}
}
6 changes: 3 additions & 3 deletions tests/FactoryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ abstract class FactoryTestCase extends TestCase
{
use TestConcerns;

protected function factory(): Factory
protected function factory(): void
{
Factory::restart();

$factory = new Factory();
$io = new BufferIO();

$factory->createComposer(io: $io, cwd: $this->path() . $this->fixture());

$this->output = $io->getOutput();

return $factory;
}
}

0 comments on commit ac1ded9

Please sign in to comment.