Skip to content

Commit

Permalink
fix: return experimental, if version is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed May 10, 2024
1 parent f7b9210 commit a39cdd9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ class Info
CONSOLE;

public const TRAP_ROOT = __DIR__ . '/..';
private const VERSION = 'experimental';

public static function version(): string
{
$versionPath = self::TRAP_ROOT . '/src/version.json';
if (!file_exists($versionPath)) {
throw new \RuntimeException('Version file not found.');
return self::VERSION;
}

/** @var array $versionData */
$versionData = json_decode(file_get_contents($versionPath), true);

if (!isset($versionData['.']) || !is_string($versionData['.'])) {
throw new \RuntimeException('Version key not found or is not a string in JSON.');
return self::VERSION;
}
return $versionData['.'];
}
Expand Down

0 comments on commit a39cdd9

Please sign in to comment.