Skip to content

Commit

Permalink
Merge pull request #7 from lneves12/master
Browse files Browse the repository at this point in the history
Add support for old package.json license format
  • Loading branch information
unindented authored Feb 3, 2019
2 parents 54858b4 + 33fade0 commit b3f7fe5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/licenseUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ const getLicenseContents = dependencyPath => {
return licensePath && wrap(readFileSync(licensePath).toString(), licenseWrap);
};

const getLicenseName = package => {
if (package.licenses) {
const licenseName = package.licenses.map(license => license.type).join(" OR ");
return package.licenses.length > 1 ? `(${licenseName})` : licenseName;
}

return package.license;
}

const getLicenseInformationForDependency = dependencyPath => {
const package = require(`${dependencyPath}/package.json`);
return {
name: package.name,
version: package.version,
author: (package.author && package.author.name) || package.author,
repository: (package.repository && package.repository.url) || package.repository,
licenseName: package.license,
licenseName: getLicenseName(package),
licenseText: getLicenseContents(dependencyPath)
};
};
Expand Down

0 comments on commit b3f7fe5

Please sign in to comment.