Created
December 9, 2023 09:08
-
-
Save suyanhanx/120f7f4b4482fcad7770ef24cf791a25 to your computer and use it in GitHub Desktop.
Generate licenses group text
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
import licenseData from './license.json' assert { type: 'json'} | |
import fs from 'node:fs' | |
let store = new Map() | |
Object.entries(licenseData).forEach(([name, data]) => { | |
const { licenses } = data | |
if (store.has(licenses)) { | |
store.get(licenses).push(name) | |
} else { | |
store.set(licenses, [name]) | |
} | |
}) | |
const finalTextArr = [] | |
let d = [...store] | |
d.sort() | |
d.forEach(([license, packages]) => { | |
finalTextArr.push(`${license}(${packages.length}) | ${packages.join(', ')}`) | |
}) | |
fs.writeFileSync('./license-summarize.txt', finalTextArr.join('\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need a license.json, it is generated by https://www.npmjs.com/package/license-checker.