(dependencies)
| 12 | ): Plugin { |
| 13 | const originalPlugin = license({ |
| 14 | thirdParty(dependencies) { |
| 15 | // https://github.com/rollup/rollup/blob/master/build-plugins/generate-license-file.js |
| 16 | // MIT Licensed https://github.com/rollup/rollup/blob/master/LICENSE-CORE.md |
| 17 | const coreLicense = fs.readFileSync( |
| 18 | new URL('../../LICENSE', import.meta.url), |
| 19 | 'utf-8', |
| 20 | ) |
| 21 | |
| 22 | const deps = sortDependencies(dependencies) |
| 23 | const licenses = sortLicenses( |
| 24 | new Set( |
| 25 | dependencies.map((dep) => dep.license).filter(Boolean) as string[], |
| 26 | ), |
| 27 | ) |
| 28 | |
| 29 | let dependencyLicenseTexts = '' |
| 30 | for (let i = 0; i < deps.length; i++) { |
| 31 | // Find dependencies with the same license text so it can be shared |
| 32 | const licenseText = deps[i].licenseText |
| 33 | const sameDeps = [deps[i]] |
| 34 | if (licenseText) { |
| 35 | for (let j = i + 1; j < deps.length; j++) { |
| 36 | if (licenseText === deps[j].licenseText) { |
| 37 | sameDeps.push(...deps.splice(j, 1)) |
| 38 | j-- |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | let text = `## ${sameDeps.map((d) => d.name).join(', ')}\n` |
| 44 | const depInfos = sameDeps.map((d) => getDependencyInformation(d)) |
| 45 | |
| 46 | // If all same dependencies have the same license and contributor names, show them only once |
| 47 | if ( |
| 48 | depInfos.length > 1 && |
| 49 | depInfos.every( |
| 50 | (info) => |
| 51 | info.license === depInfos[0].license && |
| 52 | info.names === depInfos[0].names, |
| 53 | ) |
| 54 | ) { |
| 55 | const { license, names } = depInfos[0] |
| 56 | const repositoryText = depInfos |
| 57 | .map((info) => info.repository) |
| 58 | .filter(Boolean) |
| 59 | .join(', ') |
| 60 | |
| 61 | if (license) text += `License: ${license}\n` |
| 62 | if (names) text += `By: ${names}\n` |
| 63 | if (repositoryText) text += `Repositories: ${repositoryText}\n` |
| 64 | } |
| 65 | // Else show each dependency separately |
| 66 | else { |
| 67 | for (let j = 0; j < depInfos.length; j++) { |
| 68 | const { license, names, repository } = depInfos[j] |
| 69 | |
| 70 | if (license) text += `License: ${license}\n` |
| 71 | if (names) text += `By: ${names}\n` |
nothing calls this directly
no test coverage detected