Skip to content

Commit

Permalink
refactor(yarn): Relax strictness in processAdditionalPackageInfo()
Browse files Browse the repository at this point in the history
A `package.json` file does not contain a `dist` attribute while the
output of `yarn npm view` does. Otherwise, the two formats are identical
regarding the attributes considered by ORT.

Make the code tolerate absent `dist` attributes to prepare for re-using
it to extract `AdditionalData` from a `package.json`.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Sep 11, 2024
1 parent 8272678 commit 34e2339
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/package-managers/node/src/main/kotlin/yarn2/Yarn2.kt
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,11 @@ class Yarn2(
val author = parseNpmAuthors(json)

val dist = json["dist"]
var downloadUrl = dist["tarball"].textValueOrEmpty()
var downloadUrl = dist?.get("tarball").textValueOrEmpty()

downloadUrl = fixNpmDownloadUrl(downloadUrl)

val hash = Hash.create(dist["shasum"].textValueOrEmpty())
val hash = Hash.create(dist?.get("shasum").textValueOrEmpty())

val vcsFromDownloadUrl = VcsHost.parseUrl(downloadUrl)

Expand Down

0 comments on commit 34e2339

Please sign in to comment.