-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.js
executable file
·39 lines (37 loc) · 1 KB
/
build.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
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
const fs = require('fs')
const https = require('https')
const order = require('./order')
https.request('https://spdx.org/licenses/exceptions.json', function (response) {
if (response.statusCode !== 200) {
console.error('spdx.org responded ' + response.statusCode)
process.exit(1)
}
const chunks = []
response
.on('data', function (chunk) {
chunks.push(chunk)
})
.once('end', function () {
const buffer = Buffer.concat(chunks)
const parsed = JSON.parse(buffer)
const exceptions = []
const deprecated = []
parsed.exceptions.forEach(object => {
const id = object.licenseExceptionId
if (object.isDeprecatedLicenseId) {
deprecated.push(id)
} else {
exceptions.push(id)
}
})
write('index', exceptions)
write('deprecated', deprecated)
})
}).end()
function write (file, list) {
fs.writeFileSync(
file + '.json',
JSON.stringify(list.sort(order), null, 2) + '\n'
)
}