@softwareventures/maintain-project
Version:
Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited
29 lines • 1.09 kB
JavaScript
import { combinationOperatorPrecedence } from "./spdx.js";
export function formatSpdxExpression(license) {
return formatSpdxExpressionInternal(license, null);
}
function formatSpdxExpressionInternal(license, parentOperator) {
if ("invalidText" in license) {
return license.invalidText;
}
else if ("operator" in license) {
if (parentOperator != null &&
combinationOperatorPrecedence.indexOf(license.operator) >
combinationOperatorPrecedence.indexOf(parentOperator)) {
return `(${formatSpdxExpressionInternal(license, null)})`;
}
else {
return (formatSpdxExpressionInternal(license.left, license.operator) +
" " +
license.operator +
" " +
formatSpdxExpressionInternal(license.right, license.operator));
}
}
else {
return (license.licenseId +
(license.plus ? "+" : "") +
("exceptionId" in license ? ` WITH ${license.exceptionId}` : ""));
}
}
//# sourceMappingURL=format.js.map