Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var https = require('https')
var URL = 'https://spdx.org/licenses/licenses.json'
var SPDX_URL = 'https://spdx.org/licenses/licenses.json'
var ids = {}

https.get(URL, function (response) {
https.get(SPDX_URL, function (response) {
var chunks = []
response
.on('data', function (chunk) {
Expand All @@ -14,7 +15,7 @@ https.get(URL, function (response) {
.once('end', function () {
var body = Buffer.concat(chunks)
var parsed = JSON.parse(body)
var ids = parsed.licenses
ids.spdx = parsed.licenses
.filter(function (license) {
return license.isOsiApproved
})
Expand All @@ -25,6 +26,41 @@ https.get(URL, function (response) {
return license.licenseId
})
.sort()
console.log(JSON.stringify(ids, null, 2))
if (ids.osi) compare()
})
})

var OSI_URL = 'https://opensource.org/api/license'
https.get(OSI_URL, function (response) {
var chunks = []
response
.on('data', function (chunk) {
chunks.push(chunk)
})
.once('error', function (error) {
console.error(error)
process.exit(1)
})
.once('end', function () {
var body = Buffer.concat(chunks)
var parsed = JSON.parse(body)
ids.osi = parsed
.map(function (license) {
return license.id
})
.sort()
if (ids.spdx) compare()
})
})

function compare () {
console.log(ids)
var combined = []
;[ids.spdx, ids.osi].forEach(function (list) {
list.forEach(function (id) {
if (combined.indexOf(id) === -1) combined.push(id)
})
})
combined.sort()
console.log(JSON.stringify(combined, null, 2))
}