Skip to content

Commit

Permalink
feat: add method getVersionFromFile to get version
Browse files Browse the repository at this point in the history
  • Loading branch information
efureev committed Apr 28, 2022
1 parent 11c66b1 commit 0c6cf91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ServiceProviders/HasPathHelpers.php
Expand Up @@ -127,14 +127,14 @@ public static function getViewsPath(): ?string
public static function version(): string
{
return (string)(
static::getVersionFromFile('version.json') ??
static::getVersionFromFile('composer.json')
static::getVersionFromFile(static::packagePath('version.json')) ??
static::getVersionFromFile(static::packagePath('composer.json'))
);
}

protected static function getVersionFromFile(string $filePath, string $key = 'version'): ?string
protected static function getVersionFromFile(?string $filePath, string $key = 'version'): ?string
{
if (!file_exists($filePath)) {
if (!$filePath || !file_exists($filePath)) {
return null;
}

Expand Down

0 comments on commit 0c6cf91

Please sign in to comment.