1
0

windows-installer.js 1.2 KB

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