build.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const https = require('https');
  2. const request = require('request');
  3. const fs = require('fs');
  4. request('https://atom.io/download/electron/index.json', function(error, response, body) {
  5. if (!error && response.statusCode == 200) {
  6. const allElectronVersions = JSON.parse(body);
  7. const versions = {};
  8. const fullVersions = {};
  9. const makePrintable = mapping => JSON.stringify(mapping)
  10. .replace(/,/g, ",\n\t")
  11. .replace(/{/g, "{\n\t")
  12. .replace(/}/g, "\n}");
  13. allElectronVersions.forEach(electron => {
  14. // simple list
  15. const simpleVersion = electron.version.split(".")[0] + "." + electron.version.split(".")[1];
  16. versions[simpleVersion] = electron.chrome.split(".")[0];
  17. // explicit list
  18. fullVersions[electron.version] = electron.chrome;
  19. });
  20. fs.writeFile("versions.js", `module.exports = ${makePrintable(versions)};`, function (error) {
  21. if (error) {
  22. throw error;
  23. }
  24. });
  25. fs.writeFile("full-versions.js", `module.exports = ${makePrintable(fullVersions)};`, function (error) {
  26. if (error) {
  27. throw error;
  28. }
  29. });
  30. } else {
  31. throw error;
  32. }
  33. })