( fontLicense: (typeof APILicense)[string], opts: BuildOptions, )
| 9 | |
| 10 | // Download license from Google Fonts Github repo and save to package |
| 11 | const generateLicense = async ( |
| 12 | fontLicense: (typeof APILicense)[string], |
| 13 | opts: BuildOptions, |
| 14 | ) => { |
| 15 | const licensePath = path.join(opts.dir, 'LICENSE'); |
| 16 | const copyright = fontLicense.original; |
| 17 | |
| 18 | let txt: string | undefined; |
| 19 | switch (fontLicense.license.type.toLowerCase()) { |
| 20 | case 'apache license, version 2.0': { |
| 21 | txt = apache(copyright); |
| 22 | break; |
| 23 | } |
| 24 | case 'sil open font license, 1.1': { |
| 25 | txt = ofl(copyright); |
| 26 | break; |
| 27 | } |
| 28 | case 'ubuntu font license, 1.0': { |
| 29 | txt = ufl(); |
| 30 | break; |
| 31 | } |
| 32 | default: { |
| 33 | throw new Error(`Unknown license type: ${fontLicense.license.type}`); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // Download file and write to package |
| 38 | await fs.writeFile(licensePath, txt); |
| 39 | }; |
| 40 | |
| 41 | export { generateLicense }; |
no test coverage detected