Skip to content

Commit

Permalink
Improved fetching license information for npm packages (#672)
Browse files Browse the repository at this point in the history
* added ./tmp/ to .gitignore

Signed-off-by: Jacek Puchta <jacek.puchta@dotdata.com>

* Improved fetching license information for npm packages

Signed-off-by: Jacek Puchta <jacek.puchta@dotdata.com>

* style

Signed-off-by: Jacek Puchta <jacek.puchta@dotdata.com>

---------

Signed-off-by: Jacek Puchta <jacek.puchta@dotdata.com>
  • Loading branch information
puchta authored Oct 26, 2023
1 parent 947f19d commit b3f3213
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tmp/

# Logs
logs
*.log
Expand Down
11 changes: 9 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ 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;
p.license =
body.versions?.[p.version]?.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 @@ -3095,6 +3099,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 b3f3213

Please sign in to comment.