Skip to content

Commit

Permalink
Merge pull request #7 from Kocal/fix/get-latest-release
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed Jun 29, 2024
2 parents 1a26bb5 + 019ec0c commit 1d0a416
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/BiomeJsBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ private function getVersion(): string
private function getLatestVersion(): string
{
try {
$response = $this->httpClient->request('GET', 'https://api.github.com/repos/biomejs/biome/releases/latest');
$response = $this->httpClient->request('GET', 'https://api.github.com/repos/biomejs/biome/releases');
foreach ($response->toArray() as $release) {
if (str_starts_with($release['tag_name'], 'cli/')) {
return str_replace('cli/', '', $release['tag_name']);
}
}

return str_replace('cli/', '', $response->toArray()['tag_name'] ?? throw new \Exception('Cannot get the latest version name from response JSON.'));
throw new \Exception('Unable to find the latest Biome.js CLI release.');
} catch (\Throwable $e) {
throw new \Exception('Cannot determine latest Biome.js binary version. Please specify a version in the configuration.', previous: $e);
}
Expand Down

0 comments on commit 1d0a416

Please sign in to comment.