Skip to content

Commit

Permalink
fetching license info from github repo - if none in npm metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Jacek Puchta <[email protected]>
  • Loading branch information
puchta committed Oct 26, 2023
1 parent 50ebdd7 commit 57d3750
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,11 @@ export const getNpmMetadata = async function (pkgList) {
}
p.description =
body.versions?.[p.version]?.description ||
body.description
body.description;
p.license =
body.versions?.[p.version]?.license ||
body.license
body.license ||
await getRepoLicense(body.repository?.url, undefined);
if (body.repository && body.repository.url) {
p.repository = { url: body.repository.url };
}
Expand Down Expand Up @@ -3099,6 +3100,9 @@ export const getRepoLicense = async function (repoUrl, repoMetadata) {
if (!repoUrl) {
repoUrl = toGitHubUrl(repoMetadata);
}
if (repoUrl.startsWith('git://') && repoUrl.endsWith('.git')) {
repoUrl = repoUrl.replace('git://', 'https://').slice(0, -4);
}
// Perform github lookups
if (repoUrl.indexOf("github.com") > -1) {
let apiUrl = repoUrl.replace(
Expand Down

0 comments on commit 57d3750

Please sign in to comment.