query
On this page

getLicenseFromSpdxId

lib.getLicenseFromSpdxId

Docs pulled from | This Revision | 23 minutes ago


Get the corresponding attribute in lib.licenses from the SPDX ID or warn and fallback to { shortName = <license string>; }.

For SPDX IDs, see https://spdx.org/licenses. Note that some SPDX licenses might be missing.

Type

getLicenseFromSpdxId :: String -> {
  deprecated :: Bool;
  free :: Bool;
  fullName :: String;
  redistributable :: Bool;
  shortName :: String;
  spdxId :: String;
  url :: String;
}

Examples

lib.meta.getLicenseFromSpdxId usage example

lib.getLicenseFromSpdxId "MIT" == lib.licenses.mit
=> true
lib.getLicenseFromSpdxId "mIt" == lib.licenses.mit
=> true
lib.getLicenseFromSpdxId "MY LICENSE"
=> trace: warning: getLicenseFromSpdxId: No license matches the given SPDX ID: MY LICENSE
=> { shortName = "MY LICENSE"; }
(lib.meta.getLicenseFromSpdxId)

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

getLicenseFromSpdxId =
    licstr:
    getLicenseFromSpdxIdOr licstr (
      lib.warn "getLicenseFromSpdxId: No license matches the given SPDX ID: ${licstr}" {
        shortName = licstr;
      }
    );