Created
July 1, 2024 18:40
-
-
Save kvermeille/d71c9b79f1b3c53f4af585087bbaf14f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const licenses = JSON.parse(fs.readFileSync('licenses.json', 'utf8')); | |
const output = fs.createWriteStream('all_licenses.txt'); | |
for (const [packageName, licenseInfo] of Object.entries(licenses)) { | |
const { licenses, licenseFile } = licenseInfo; | |
output.write(`Package: ${packageName}\n`); | |
output.write(`Licenses: ${licenses}\n`); | |
if (licenseFile) { | |
const licenseText = fs.readFileSync(licenseFile, 'utf8'); | |
output.write(`\nLicense Text:\n${licenseText}\n`); | |
} else { | |
output.write(`\nLicense Text: Not available\n`); | |
} | |
output.write("\n" + "=".repeat(80) + "\n\n"); | |
} | |
output.end(); | |
console.log("All licenses compiled into 'all_licenses.txt'."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment