Skip to content

Instantly share code, notes, and snippets.

@kvermeille
Created July 1, 2024 18:40
Show Gist options
  • Save kvermeille/d71c9b79f1b3c53f4af585087bbaf14f to your computer and use it in GitHub Desktop.
Save kvermeille/d71c9b79f1b3c53f4af585087bbaf14f to your computer and use it in GitHub Desktop.
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