Skip to content

Commit

Permalink
refactor(node): Factor out mapNpmLicenses()
Browse files Browse the repository at this point in the history
Prepare for re-use in upcoming changes.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Sep 10, 2024
1 parent 4e19bbd commit aa46f27
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ internal fun parseNpmLicenses(json: JsonNode): Set<String> {
licenseNode["type"]?.textValue()
}

return declaredLicenses.mapNotNullTo(mutableSetOf()) { declaredLicense ->
return declaredLicenses.mapNpmLicenses()
}

internal fun Collection<String>.mapNpmLicenses(): Set<String> =
mapNotNullTo(mutableSetOf()) { declaredLicense ->
when {
// NPM does not mean https://unlicense.org/ here, but the wish to not "grant others the right to use
// a private or unpublished package under any terms", which corresponds to SPDX's "NONE".
Expand All @@ -138,7 +142,6 @@ internal fun parseNpmLicenses(json: JsonNode): Set<String> {
else -> declaredLicense.takeUnless { it.isBlank() }
}
}
}

/**
* Parse information about the VCS from the [package.json][node] file of a module.
Expand Down

0 comments on commit aa46f27

Please sign in to comment.