-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview-licenses.js
29 lines (26 loc) · 959 Bytes
/
view-licenses.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import fs from 'fs'
import util from 'util'
const ignoreDetails = ['Apache-2.0', 'MIT', 'ISC', 'BSD-2-Clause', 'BSD-3-Clause'];
(async () => {
const licensesRaw = await util.promisify(fs.readFile)('licenses.json').then(b => b.toString())
const licenses = JSON.parse(licensesRaw)
const packages = Object.keys(licenses)
const licensesGrouped = {}
packages.forEach(pkg => {
const license = licenses[pkg].licenses
if(!licensesGrouped[license]) {
licensesGrouped[license] = []
}
licensesGrouped[license].push(pkg)
})
Object.keys(licensesGrouped).forEach(licenseName => {
console.log(licenseName, '(' + licensesGrouped[licenseName].length + ')')
if(!ignoreDetails.includes(licenseName)) {
licensesGrouped[licenseName].forEach((pkg, i) => {
console.log(' ' + (i + 1) + '. ' + pkg)
})
}
})
})().then(() => {
// noop
})