Skip to content

Commit

Permalink
refactor(stack): Simplify toPackage() a bit
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Jul 3, 2024
1 parent 34e7e95 commit 28fe497
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions plugins/package-managers/stack/src/main/kotlin/Stack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,15 @@ class Stack(
version = version
)

val fallback = Package.EMPTY.copy(
if (location == null || location.type == HACKAGE_PACKAGE_TYPE) {
downloadCabalFile(id)?.let { return parseCabalFile(it) }
}

return Package.EMPTY.copy(
id = id,
purl = id.toPurl(),
declaredLicenses = setOf(license)
)

return when (location?.type) {
null, HACKAGE_PACKAGE_TYPE -> {
// Enrich the package with additional metadata from Hackage.
downloadCabalFile(id)?.let {
parseCabalFile(it)
} ?: fallback
}

else -> fallback
}
}

private fun getPackageUrl(name: String, version: String) = "https://hackage.haskell.org/package/$name-$version"
Expand Down

0 comments on commit 28fe497

Please sign in to comment.