getLicenseFromSpdxIdOr
lib.getLicenseFromSpdxIdOr
Docs pulled from | This Revision | 2 days ago
Get the corresponding attribute in lib.licenses from the SPDX ID or fallback to the given default value.
For SPDX IDs, see https://spdx.org/licenses. Note that some SPDX licenses might be missing.
Inputs
licstr
- 1. SPDX ID string to find a matching license
default
- 2. Fallback value when a match is not found
Type
getLicenseFromSpdxIdOr :: str -> Any -> Any
Examples
lib.meta.getLicenseFromSpdxIdOr
usage example
lib.getLicenseFromSpdxIdOr "MIT" null == lib.licenses.mit
=> true
lib.getLicenseFromSpdxId "mIt" null == lib.licenses.mit
=> true
lib.getLicenseFromSpdxIdOr "MY LICENSE" lib.licenses.free == lib.licenses.free
=> true
lib.getLicenseFromSpdxIdOr "MY LICENSE" null
=> null
lib.getLicenseFromSpdxIdOr "MY LICENSE" (builtins.throw "No SPDX ID matches MY LICENSE")
=> error: No SPDX ID matches MY LICENSE