Comparing version 3.0.0 to 4.0.0
66
index.js
@@ -47,36 +47,39 @@ module.exports = licensee | ||
function findIssues (configuration, tree, issues) { | ||
function findIssues (configuration, tree, results) { | ||
var dependencies = tree.children | ||
// If there are dependencies, check license metadata. | ||
if (typeof dependencies === 'object') { | ||
return dependencies | ||
.reduce(function (issues, tree) { | ||
if (!acceptablePackage(configuration, tree)) { | ||
issues.push({ | ||
name: tree.package.name, | ||
license: tree.package.license, | ||
version: tree.package.version, | ||
parent: tree.parent, | ||
path: tree.path | ||
}) | ||
} | ||
// Recurse dependencies. | ||
return findIssues(configuration, tree, issues) | ||
}, issues) | ||
} else return issues | ||
dependencies.forEach(function (tree) { | ||
results.push(resultForPackage(configuration, tree)) | ||
findIssues(configuration, tree, results) | ||
}) | ||
return results | ||
} else return results | ||
} | ||
function acceptablePackage (configuration, tree) { | ||
function resultForPackage (configuration, tree) { | ||
var licenseExpression = configuration.license | ||
var whitelist = configuration.whitelist | ||
return ( | ||
// Is the package on the whitelist? | ||
Object.keys(whitelist).some(function (name) { | ||
return ( | ||
tree.package.name === name && | ||
satisfies(tree.package.version, whitelist[name]) === true | ||
) | ||
}) || | ||
// Does the package's license metadata match configuration? | ||
( | ||
var result = { | ||
name: tree.package.name, | ||
license: tree.package.license, | ||
author: tree.package.author, | ||
contributors: tree.package.contributors, | ||
repository: tree.package.repository, | ||
homepage: tree.package.homepage, | ||
version: tree.package.version, | ||
parent: tree.parent, | ||
path: tree.path | ||
} | ||
var whitelisted = Object.keys(whitelist).some(function (name) { | ||
return ( | ||
tree.package.name === name && | ||
satisfies(tree.package.version, whitelist[name]) === true | ||
) | ||
}) | ||
if (whitelisted) { | ||
result.approved = true | ||
result.whitelisted = true | ||
} else { | ||
var matchesRule = ( | ||
licenseExpression && | ||
@@ -89,3 +92,10 @@ validSPDX(licenseExpression) && | ||
) | ||
) | ||
if (matchesRule) { | ||
result.approved = true | ||
result.rule = true | ||
} else { | ||
result.approved = false | ||
} | ||
} | ||
return result | ||
} |
{ | ||
"name": "licensee", | ||
"description": "check dependency licenses against rules", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com/)", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21418
92