From b890b920e72364b88e0877a3e19bd3d5807ecc34 Mon Sep 17 00:00:00 2001 From: Gabi Dobocan Date: Sun, 19 Feb 2023 00:35:29 +0200 Subject: [PATCH] feat: api now supports custom license policies --- src/index.js | 3 ++- src/issues/license.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index a70ba3e..28b1332 100644 --- a/src/index.js +++ b/src/index.js @@ -14,6 +14,7 @@ const getReport = async ({ minDisplayedSeverity = 'high', width = 1500, maxDepth = 7, + licensePolicy, onProgress = () => {}, }) => { const errors = []; @@ -56,7 +57,7 @@ const getReport = async ({ licenseUsage = await getLicenseUsage({ dependencies: includeDev ? dGraph.all : dGraph.prodDependencies, }); - licenseIssues = await getLicenseIssues({licenseUsage, packageGraph}); + licenseIssues = await getLicenseIssues({licenseUsage, packageGraph, licensePolicy}); } catch (error) { errors.push(error); } diff --git a/src/issues/license.js b/src/issues/license.js index 5316d06..f88bbbf 100644 --- a/src/issues/license.js +++ b/src/issues/license.js @@ -102,7 +102,7 @@ module.exports = { return licenseUsage.sort((a, b) => b.dependencies.length - a.dependencies.length); }, - getLicenseIssues: ({licenseUsage, packageGraph}) => { + getLicenseIssues: ({licenseUsage, packageGraph, licensePolicy = DEFAULT_POLICY}) => { const issues = []; licenseUsage.forEach(({string, meta, dependencies}) => { @@ -169,7 +169,7 @@ module.exports = { }); } - Object.entries(DEFAULT_POLICY).forEach(([severity, includes]) => { + Object.entries(licensePolicy).forEach(([severity, includes]) => { if (includes.includes(string)) { issues.push({ severity,