Skip to content

Commit

Permalink
feat: api now supports custom license policies
Browse files Browse the repository at this point in the history
  • Loading branch information
gabidobo committed Feb 18, 2023
1 parent ff0c387 commit b890b92
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const getReport = async ({
minDisplayedSeverity = 'high',
width = 1500,
maxDepth = 7,
licensePolicy,
onProgress = () => {},
}) => {
const errors = [];
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/issues/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b890b92

Please sign in to comment.