const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller
const path = require('path')

getInstallerConfig()
  .then(createWindowsInstaller)
  .catch((error) => {
    console.error(error.message || error)
    process.exit(1)
  })

function getInstallerConfig () {
  console.log('creating windows installer')
  const rootPath = path.join('./')
  const outPath = path.join(rootPath, 'build_win')

  return Promise.resolve({
    appDirectory: path.join(outPath, 'LoehnApp-win32-x64/'),
    authors: 'coda KG',
    noMsi: true,
    outputDirectory: path.join(outPath, 'windowsinstaller'),
    exe: 'LoehnApp.exe',
    setupExe: 'LoehnAppInstaller.exe',
    setupIcon: path.join(__dirname, 'assets/icon/win_icon.ico'), // safer path
    loadingGif: path.join(__dirname, 'loehn_loader.gif') 
  })
}