forked from jslicense/spdx-exceptions.json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
executable file
·33 lines (32 loc) · 905 Bytes
/
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
#!/usr/bin/env node
var fs = require('fs')
var https = require('https')
https.request('https://spdx.org/licenses/exceptions.json', function (response) {
if (response.statusCode !== 200) {
console.error('spdx.org responded ' + response.statusCode)
process.exit(1)
}
var chunks = []
response
.on('data', function (chunk) {
chunks.push(chunk)
})
.once('end', function () {
var buffer = Buffer.concat(chunks)
var parsed = JSON.parse(buffer)
var output = parsed.exceptions
.map(function (exception) {
return exception.licenseExceptionId
})
.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase())
})
fs.writeFile(
'index.json',
JSON.stringify(output, null, 2) + '\n',
function (error) {
if (error) throw error
}
)
})
}).end()