-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.mjs
52 lines (46 loc) · 1.81 KB
/
build.mjs
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
51
52
import fs from 'fs';
import fetch from 'node-fetch';
import { compareVersions } from 'compare-versions';
const electronVersions = {};
const electronFullVersions = {};
const chromiumVersions = {};
const chromiumFullVersions = {};
const makePrintable = mapping => JSON.stringify(mapping, null, "\t");
await fetch("https://electronjs.org/headers/index.json")
.then(body => body.json())
.then(allElectronVersions => {
allElectronVersions
.sort(({ version: a }, { version: b }) => compareVersions(a, b))
.forEach(electron => {
if (!electron.version.includes("nightly")) {
// simple list
const simpleVersion = electron.version.split(".")[0] + "." + electron.version.split(".")[1];
const chromeVersion = electron.chrome.split(".")[0];
electronVersions[simpleVersion] = chromeVersion;
chromiumVersions[chromeVersion] = chromiumVersions[chromeVersion] || simpleVersion;
// explicit list
electronFullVersions[electron.version] = electron.chrome;
if (!chromiumFullVersions[electron.chrome]) {
chromiumFullVersions[electron.chrome] = [];
}
chromiumFullVersions[electron.chrome].push(electron.version);
}
});
[
{list: electronVersions, file: "versions"},
{list: electronFullVersions, file: "full-versions"},
{list: chromiumVersions, file: "chromium-versions"},
{list: chromiumFullVersions, file: "full-chromium-versions"},
].forEach((obj) => {
fs.writeFile(`${obj.file}.js`, `module.exports = ${makePrintable(obj.list)};`, function (error) {
if (error) {
throw error;
}
});
fs.writeFile(`${obj.file}.json`, JSON.stringify(obj.list), function (error) {
if (error) {
throw error;
}
});
});
});