Skip to content

Commit

Permalink
Revert "Don't calculate basePath in LibraryProperties::buildNames"
Browse files Browse the repository at this point in the history
This reverts commit 9b73d04.
  • Loading branch information
gmazzap committed Mar 9, 2022
1 parent 9b73d04 commit 7c1d1a1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Properties/LibraryProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public static function new(string $composerJsonFile, ?string $baseUrl = null): L
$properties[self::PROP_VERSION] = $version;
}

$basePath = dirname($composerJsonFile);
[$baseName, $name] = static::buildNames($composerJsonData, $composerJsonFile);
[$basePath, $baseName, $name] = static::buildNames($composerJsonData, $composerJsonFile);
if (empty($properties[self::PROP_NAME])) {
$properties[self::PROP_NAME] = $name;
}
Expand All @@ -95,11 +94,15 @@ public static function new(string $composerJsonFile, ?string $baseUrl = null): L

/**
* @param array $composerJsonData
* @param string $composerJsonFile
*
* @return array{string, string}
* @return array{string, string, string}
*/
private static function buildNames(array $composerJsonData): array
private static function buildNames(array $composerJsonData, string $composerJsonFile): array
{
$composerName = (string) ($composerJsonData['name'] ?? '');
$basePath = dirname($composerJsonFile);

$packageNamePieces = explode('/', $composerName, 2);
$basename = implode('-', $packageNamePieces);
// "inpsyde/foo-bar-baz" => "Inpsyde Foo Bar Baz"
Expand All @@ -108,7 +111,7 @@ private static function buildNames(array $composerJsonData): array
MB_CASE_TITLE
);

return [$basename, $name];
return [$basePath, $basename, $name];
}

/**
Expand Down

0 comments on commit 7c1d1a1

Please sign in to comment.