Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add security property to index #8

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 35 additions & 2 deletions dist-indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const fs = require('fs')
, `${githubContentUrl}/src/node.h`
]
, ltsVersionUrl = `${githubContentUrl}/src/node_version.h`
, isSecurityUrl = `${githubContentUrl}/src/node_version.h`
, githubOptions = { headers: {
'accept': 'text/plain,application/vnd.github.v3.raw'
} }
Expand Down Expand Up @@ -338,6 +339,26 @@ function fetchLtsVersion (gitref, callback) {
})
}

function fetchIsSecurity (gitref, callback) {
var security = cacheGet(gitref, 'security')

if (security || security === false)
return setImmediate(callback.bind(null, null, security))

fetch(isSecurityUrl, gitref, function (err, rawData) {
if (err)
return callback(err)

var m = rawData.match(/^#define NODE_VERSION_IS_SECURITY_RELEASE 1$/m)
if (m) {
security = true
} else
security = false

cachePut(gitref, 'security', security)
callback(null, security)
})
}

function dirDate (dir, callback) {
fs.readdir(path.join(argv.dist, dir), function (err, files) {
Expand Down Expand Up @@ -392,6 +413,7 @@ function inspectDir (dir, callback) {
, zlibVersion
, modVersion
, ltsVersion
, isSecurity
, date

if (!gitref) {
Expand All @@ -412,7 +434,7 @@ function inspectDir (dir, callback) {

files = _files

var done = after(8, afterAll)
var done = after(9, afterAll)

dirDate(dir, function (err, _date) {
if (err)
Expand Down Expand Up @@ -484,6 +506,15 @@ function inspectDir (dir, callback) {
ltsVersion = version
done()
})

fetchIsSecurity (gitref, function (err, security) {
if (err) {
console.error(err)
console.error('(ignoring error fetching security for %s)', gitref)
}
isSecurity = security
done()
})
})

function afterAll (err) {
Expand All @@ -504,6 +535,7 @@ function inspectDir (dir, callback) {
, openssl : sslVersion
, modules : modVersion
, lts : ltsVersion
, security : isSecurity
})
}
}
Expand Down Expand Up @@ -533,7 +565,7 @@ function afterMap (err, dirs) {
}

jsonOut.write('[\n')
tabWrite('version', 'date', 'files', 'npm', 'v8', 'uv', 'zlib', 'openssl', 'modules', 'lts')
tabWrite('version', 'date', 'files', 'npm', 'v8', 'uv', 'zlib', 'openssl', 'modules', 'lts', 'security')

dirs.forEach(function (dir, i) {
jsonOut.write(JSON.stringify(dir) + (i != dirs.length - 1 ? ',\n' : '\n'))
Expand All @@ -548,6 +580,7 @@ function afterMap (err, dirs) {
, dir.openssl
, dir.modules
, dir.lts
, dir.security
)
})

Expand Down