Skip to content

Instantly share code, notes, and snippets.

@suyanhanx
Created December 9, 2023 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suyanhanx/120f7f4b4482fcad7770ef24cf791a25 to your computer and use it in GitHub Desktop.
Save suyanhanx/120f7f4b4482fcad7770ef24cf791a25 to your computer and use it in GitHub Desktop.
Generate licenses group text
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'))
@suyanhanx
Copy link
Author

Need a license.json, it is generated by https://www.npmjs.com/package/license-checker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment