UNPKG

@softwareventures/maintain-project

Version:

Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited

35 lines 1.22 kB
import spdxCorrect from "spdx-correct"; import { parseSpdxExpression } from "./parse.js"; import { formatSpdxExpression } from "./format.js"; export function parseAndCorrectSpdxExpression(text) { return correctSpdxLicense(parseSpdxExpression(text)); } const proprietaryLicenses = new Set(["PROPRIETARY", "UNLICENSED"]); export function correctSpdxLicense(license) { if ("operator" in license) { return { left: correctSpdxLicense(license.left), operator: license.operator, right: correctSpdxLicense(license.right) }; } else if ("licenseId" in license && proprietaryLicenses.has(license.licenseId.toUpperCase())) { return license; } else if ("exceptionId" in license) { return { ...correctSpdxLicense({ licenseId: license.licenseId, plus: license.plus }), exceptionId: license.exceptionId }; } else { const correctedExpression = spdxCorrect(formatSpdxExpression(license)); if (correctedExpression == null) { return license; } else { return parseSpdxExpression(correctedExpression); } } } //# sourceMappingURL=correct.js.map