forked from compat-table/compat-table
-
Notifications
You must be signed in to change notification settings - Fork 33
/
versions.js
43 lines (38 loc) · 1.18 KB
/
versions.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
40
41
42
43
module.exports = function(engine) {
const out = {}
const versions = require('fs').readFileSync(`./${engine}.versions`).toString().replace(/v/g, '').trim().split('\n')
const prev = { flagged: { data: '' }, unflagged: { data: '' } }
function serialize (v, harmony = '') {
try {
const data = require(`./results/${engine}/${v}${harmony}.json`)
return {
engine: data._engine,
data: JSON.stringify(data, (k, v) => /^_/.test(k) ? 0 : v)
}
}
catch(e) {}
}
versions.unshift('nightly')
versions.forEach((v) => {
if(!v) return; // ignore empty lines
const unflagged = serialize(v)
const cur = {
unflagged: unflagged,
flagged: serialize(v, '--harmony') || unflagged
}
if (cur.unflagged.data !== prev.unflagged.data || cur.flagged.data !== prev.flagged.data || prev.parent === 'nightly') {
prev.parent = v
out[v] = []
}
out[prev.parent].push({
version: v,
engine: cur.unflagged.engine
})
prev.flagged = cur.flagged
prev.unflagged = cur.unflagged
})
return out
}
if (require.main === module) {
console.log(JSON.stringify(module.exports(process.argv[2] || 'v8'), null, 2))
}