Skip to content

Commit

Permalink
Merge pull request #302 from nextcloud-libraries/backport/293/stable1
Browse files Browse the repository at this point in the history
[stable1] fix(REUSELicensesPlugin): remove duplicates in license files
  • Loading branch information
susnux committed Aug 22, 2024
2 parents f6b64de + 194332b commit 3a3d05e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/plugins/REUSELicensesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ export function REUSELicensesPlugin(options: REUSELicensesPluginOptions = {}): P
}
}

const packages = new Set((
await Promise.all(
[...modules.values()]
.map(sanitizeName)
.map(findPackage),
)).filter(Boolean),
)
// Get all package license data of the modules
const allPackages = (await Promise.all(
[...modules.values()]
.map(sanitizeName)
.map(findPackage),
)).filter(Boolean)

// Remove duplicates by serialized package license data
const packages = [...new Map(allPackages.map((item) => [JSON.stringify(item), item])).values()]

const sortedPackages = [...packages].sort((a, b) => a.name.localeCompare(b.name) || a.version.localeCompare(b.version, undefined, { numeric: true }))
const authors = new Set(sortedPackages.map(({ author }) => author))
Expand Down

0 comments on commit 3a3d05e

Please sign in to comment.