windows-installer.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. //Taken from Electron API Demos
  3. //https://github.com/electron/electron-api-demos/blob/master/script/installer.js
  4. const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller;
  5. const path = require('path');
  6. const rimraf = require('rimraf');
  7. deleteOutputFolder()
  8. .then(getInstallerConfig)
  9. .then(createWindowsInstaller)
  10. .catch((error) => {
  11. console.error(error.message || error);
  12. process.exit(1);
  13. });
  14. function getInstallerConfig() {
  15. const rootPath = path.join(__dirname, '..');
  16. const outPath = path.join(rootPath, 'out');
  17. return Promise.resolve({
  18. appDirectory: path.join(outPath, 'flasher.js-win32-x64'),
  19. iconUrl: 'https://raw.githubusercontent.com/thingssdk/flasher.js/resources/icon.ico',
  20. loadingGif: path.join(rootPath, 'resources', 'loading.gif'),
  21. noMsi: true,
  22. outputDirectory: path.join(outPath, 'installers'),
  23. setupExe: 'flasher.js-setup.exe',
  24. setupIcon: path.join(rootPath, 'resources', 'icon.ico'),
  25. skipUpdateIcon: true
  26. });
  27. }
  28. function deleteOutputFolder() {
  29. return new Promise((resolve, reject) => {
  30. rimraf(path.join(__dirname, '..', 'out', 'installers'), error => {
  31. if (error) reject(error);
  32. else resolve();
  33. });
  34. });
  35. }