Skip to content

Commit

Permalink
If package has no versions, do not convert to a detailed package
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Apr 10, 2024
1 parent f02e461 commit 4064551
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Package/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Winter\Packager\Package;

use Winter\Packager\Exceptions\PackagistException;

/**
* Package collection.
*
Expand Down Expand Up @@ -197,7 +199,11 @@ public function toDetailed(): static
continue;
}

$package = $package->toDetailed();
try {
$package = $package->toDetailed();
} catch (PackagistException $e) {
// If we can't get detailed information, just leave it as-is.
}
}

return $this;
Expand Down
4 changes: 4 additions & 0 deletions src/Package/Packagist.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public static function getPackage(
}
}

if (!count($versions)) {
throw new PackagistException('Package has no versions');
}

if (is_null($version)) {
return $versions[array_keys($versions)[0]];
}
Expand Down

0 comments on commit 4064551

Please sign in to comment.