gokatz
5/25/2017 - 5:21 AM

autoUpdater Snippet in main.js file

autoUpdater Snippet in main.js file

const winston = require('winston');

winston.configure({
  transports: [
    new (winston.transports.File)({ filename: `path/to/logfile/file.log` })
  ]
});

winston.log('info', app.getVersion());

let seedUrl = 'http://localhost:80/update/osx/1.0.0'; // replace your seed url. If you follow the post and running for mac alone, then this should be your seed url

autoUpdater.setFeedURL(seedUrl);

winston.log('info', 'initiating version check');
autoUpdater.checkForUpdates();

autoUpdater.on('checking-for-update', () => {
  winston.log('info', 'checking-for-update');
});

autoUpdater.on('update-available', () => {
  winston.log('info', 'update-available');
});

autoUpdater.on('update-not-available', () => {
  winston.log('info', 'update-not-available');
});

autoUpdater.on('update-downloaded', () => {
  winston.log('info', 'update-downloaded');
  // you may need to ask user for confirmation
  autoUpdater.quitAndInstall()
});

autoUpdater.on('error', (data) => {
  winston.log('error', 'error-on-update');
  winston.log('info', data);
});