Skip to content

Commit

Permalink
feat(composer): Use PackageManager.getFallbackProjectName
Browse files Browse the repository at this point in the history
If no name can be determined from the package metadata, use the
`getFallbackProjectName` helper function to align with other package
manager implementations.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Jan 16, 2024
1 parent c5671ee commit 0c748f4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/package-managers/composer/src/main/kotlin/Composer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,15 @@ class Composer(
val json = definitionFile.readTree()
val homepageUrl = json["homepage"].textValueOrEmpty()
val vcs = parseVcsInfo(json)
val rawName = json["name"]?.textValue() ?: definitionFile.parentFile.name
val rawName = json["name"]?.textValue()
val namespace = rawName?.substringBefore("/", missingDelimiterValue = "").orEmpty()
val name = rawName?.substringAfter("/") ?: getFallbackProjectName(analysisRoot, definitionFile)

return Project(
id = Identifier(
type = managerName,
namespace = rawName.substringBefore('/'),
name = rawName.substringAfter('/'),
namespace = namespace,
name = name,
version = json["version"].textValueOrEmpty()
),
definitionFilePath = VersionControlSystem.getPathInfo(definitionFile).path,
Expand Down

0 comments on commit 0c748f4

Please sign in to comment.