Skip to content

Commit

Permalink
Fix setting non-existing composer.json properties
Browse files Browse the repository at this point in the history
  • Loading branch information
christianlerch committed Feb 15, 2024
1 parent 5552bab commit e1e48b3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ private function getPackagePathsByName(): array

private function addPackageRepository(object $composerJson, string $packagePath): void
{
if (!property_exists($composerJson, 'repositories')) {
$composerJson->repositories = [];
}

array_unshift($composerJson->repositories, (object)[
'type' => 'path',
'url' => preg_replace("|^$this->workingDirectory/|", '', $packagePath),
Expand All @@ -127,6 +131,10 @@ private function addPackageRepository(object $composerJson, string $packagePath)

private function setPackageVersion(object $composerJson, string $packageName): void
{
if (!property_exists($composerJson, 'require')) {
$composerJson->require = (object)[];
}

$composerJson->require->$packageName = '@dev';
}

Expand Down

0 comments on commit e1e48b3

Please sign in to comment.