Skip to content

Commit

Permalink
Improved fetching license information for npm packages
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 325d61a commit 3938f30
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,11 @@ export const getNpmMetadata = async function (pkgList) {
body = res.body;
metadata_cache[key] = body;
}
p.description = body.description;
p.license = body.license;
p.description = body.versions?.[p.version]?.description || body.description;

Check failure on line 333 in utils.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Insert `⏎·······`

Check failure on line 333 in utils.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-latest)

Insert `⏎·······`

Check failure on line 333 in utils.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `⏎·······`

Check failure on line 333 in utils.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Insert `⏎·······`
p.license =
body.versions?.[p.version]?.license ||

Check failure on line 335 in utils.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `··`

Check failure on line 335 in utils.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-latest)

Delete `··`

Check failure on line 335 in utils.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `··`

Check failure on line 335 in utils.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Delete `··`
body.license ||

Check failure on line 336 in utils.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `··`

Check failure on line 336 in utils.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-latest)

Delete `··`

Check failure on line 336 in utils.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `··`

Check failure on line 336 in utils.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Delete `··`
(await getRepoLicense(body.repository?.url, undefined));

Check failure on line 337 in utils.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `··`

Check failure on line 337 in utils.js

View workflow job for this annotation

GitHub Actions / build (18.x, ubuntu-latest)

Delete `··`

Check failure on line 337 in utils.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `··`

Check failure on line 337 in utils.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Delete `··`
if (body.repository && body.repository.url) {
p.repository = { url: body.repository.url };
}
Expand Down Expand Up @@ -3095,6 +3098,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 3938f30

Please sign in to comment.