forked from williamkapke/node-compat-table
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-nightly.js
50 lines (45 loc) · 1.44 KB
/
build-nightly.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
44
45
46
47
48
49
50
var pug = require('pug')
var utils = require('./utils.js');
var $escape = utils.$escape
var $get = utils.$get
var testers = utils.objectifiedTesters();
var results = {
v8: require(`./results/v8/bleeding.json`),
chakracore: require(`./results/chakracore/nightly.json`)
}
var headers = {
v8: {
super: 'v8',
version: results.v8._version.replace(/-.*/, ''),
includes: [{
version: results.v8._version.replace(/-.*/, ''),
engine: results.v8._engine
}]
},
chakracore: {
super: 'Chakra',
version: results.v8._version.replace(/-.*/, ''),
includes: [{
version: results.chakracore._version.replace(/-.*/, ''),
engine: results.chakracore._engine
}]
}
}
var html = pug.renderFile('index.pug', {
pretty: true,
headers: headers,
testers: testers,
results: function (nodeVersion, esVersion, path) {
var result = $get(results[nodeVersion], esVersion, path)
if (result === undefined) return ''
var title = result === true ? 'Test passed' : typeof result === 'string' ? result : 'Test failed'
result = result === true ? 'Yes' : typeof result === 'string' ? 'Error' : 'No'
return `<div class="${result}" title="${$escape(title)}">${result}</div>`
},
requiresFlag: () => false,
percent: function (nodeVersion, esVersion) {
var data = $get(results[nodeVersion], esVersion)
return data ? Math.floor(data._percent * 100) : ''
}
})
require('fs').writeFileSync('./nightly.html', html)