How to use the electron-updater.autoUpdater.on function in electron-updater

To help you get started, we’ve selected a few electron-updater examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ooni / probe-desktop / main / index.js View on Github external
// On macOS it's normal to quit the app only when you do apple-Q
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

function sendStatusToWindow(text) {
  const aboutWindow = openAboutWindow()
  log.info(text)
  aboutWindow.webContents.send('update-message', text)
}

autoUpdater.on('checking-for-update', () => {
  sendStatusToWindow('Checking for update...')
})
autoUpdater.on('update-available', () => {
  sendStatusToWindow('Update available.')
})
autoUpdater.on('update-not-available', () => {
  sendStatusToWindow('Update not available.')
})
autoUpdater.on('error', (err) => {
  sendStatusToWindow('Error in auto-updater. ' + err)
})
autoUpdater.on('download-progress', (progressObj) => {
  let log_message = 'Download speed: ' + progressObj.bytesPerSecond
  log_message = log_message + ' - Downloaded ' + progressObj.percent + '%'
  log_message = log_message + ' (' + progressObj.transferred + '/' + progressObj.total + ')'
  sendStatusToWindow(log_message)
})
autoUpdater.on('update-downloaded', () => {
  sendStatusToWindow('Update downloaded. Quitting and installing.')
github taurusai / kungfu / app / src / main / index.js View on Github external
});
    autoUpdater.on('checking-for-update', () => {
        sendUpdateMessage(mainWindow, message.checking)
    });
    autoUpdater.on('update-available', (info) => {
        sendUpdateMessage(mainWindow, message.updateAva)
    });
    autoUpdater.on('update-not-available', (info) => {
        sendUpdateMessage(mainWindow, message.updateNotAva)
    });

    // 更新下载进度事件
    autoUpdater.on('download-progress', (progressObj) => {
        mainWindow.webContents.send('downloadProgress', progressObj)
    })
    autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) => {
        dialog.showMessageBox({
            type: 'question',
            title: '提示',
            defaultId: 0,
            cancelId: 1,
            message: "检测到新版本,更新会退出应用,是否立即更新?",
            buttons: ['立即更新', '否'],
            icon: path.join(__resources, 'icon', 'icon.png')
        }, (index) => {
            if(index === 0){
				KillAll().then(() => {
					setImmediate(() => {
						autoUpdater.quitAndInstall(); 
						app.quit()
					})
				})
github AGProjects / sylk-webrtc / app / index.js View on Github external
message: 'Current version is up-to-date.',
            buttons: ['OK']
        });
        updater.enabled = true;
        updater = null;
    }
});

// There is progress in the download
autoUpdater.on('download-progress', (progressObj) => {
    progressBar.value = progressObj.percent;
    progressBar.detail =  `Downloading...  ${(progressObj.bytesPerSecond / 1000).toFixed(2)} KB/s (${(progressObj.transferred / 1000000).toFixed(2)} MB / ${(progressObj.total / 1000000).toFixed(2)} MB)`;
});

// The update is downloaded
autoUpdater.on('update-downloaded', () => {
    progressBar.setCompleted();
    progressBar.close();
    
    dialog.showMessageBox({
        title: 'Ready to Install',
        message: 'The software has been downloaded. Click Restart to relaunch the new version...',
        buttons: ['Restart']
    }, () => {
        ensureSafeQuitAndInstall();
    });
});

// for platform specific tricks
const isDarwin = process.platform === 'darwin';
const isLinux = process.platform === 'linux';
github bep713 / madden-franchise-editor / main.js View on Github external
function addAutoUpdaterListeners() {
  function sendStatusToWindow(text) {
    // mainWindow.webContents.send('message', text);
  }

  autoUpdater.on('checking-for-update', () => {
    mainWindow.webContents.send('checking-for-updates');
  });

  autoUpdater.on('update-available', (info) => {
    mainWindow.webContents.send('update-ready');
  });

  autoUpdater.on('update-not-available', (info) => {
    mainWindow.webContents.send('update-not-available');
  });

  autoUpdater.on('error', (err) => {
    mainWindow.webContents.send('update-error', err);
  });

  autoUpdater.on('download-progress', (progressObj) => {
    let log_message = "Download speed: " + progressObj.bytesPerSecond;
    log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
    log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
    mainWindow.webContents.send('update-progress', progressObj);
  });

  autoUpdater.on('update-downloaded', (info) => {
    mainWindow.webContents.send('update-downloaded');
github oliverschwendener / ueli / src / js / main.js View on Github external
function setUpAutoUpdater() {
  autoUpdater.checkForUpdates()

  autoUpdater.on('update-available', (info) => {
    mainWindow.webContents.send('update-available')
  })

  autoUpdater.on('update-not-available', (info) => {
    console.log('Up to date')
    mainWindow.webContents.send('up-to-date')
  })

  autoUpdater.on('error', (err) => {
    console.log('Error while checking for updates')
  })

  autoUpdater.on('download-progress', (progressObj) => {
    console.log('Downloading')
  })
github stream-labs / streamlabs-obs / updater / Updater.js View on Github external
this.finished = true;
      this.browserWindow.close();
    });

    autoUpdater.on('download-progress', progress => {
      this.updateState.percent = progress.percent;
      this.updateState.bytesPerSecond = progress.percent;

      if (progress.percent === 100) {
        this.updateState.installing = true;
      }

      this.pushState();
    });

    autoUpdater.on('update-downloaded', () => {
      this.updateState.installing = true;
      this.pushState();
      autoUpdater.quitAndInstall();
    });

    autoUpdater.on('error', () => {
      this.updateState.error = true;
      this.pushState();
    });

    ipcMain.on('autoUpdate-getState', () => {
      this.pushState();
    });
  }
github sakazuki / node-red-desktop / src / main / auto-update.ts View on Github external
constructor(window: BrowserWindow, status: AppStatus) {
    this.window = window;
    this.status = status;
    autoUpdater.logger = log;
    autoUpdater.on("checking-for-update", () => this.onCheckingForUpdate());
    autoUpdater.on("update-available", info => this.onUpdateAvailable(info));
    autoUpdater.on("update-not-available", info =>
      this.onUpdateNotAvaialable(info)
    );
    autoUpdater.on("error", err => this.onError(err));
    autoUpdater.on("download-progress", progressObj =>
      this.onDownloadProgress(progressObj)
    );
    autoUpdater.on("update-downloaded", info => this.onUpdateDownloaded(info));
    if (this.status.autoCheckUpdate) this.checkUpdates(false);
  }
github blocknetdx / block-dx / index.js View on Github external
ipcMain.once('getUpdateWindowType', e => {
    e.returnValue = windowType;
  });
  ipcMain.removeAllListeners('hideCheckbox');
  ipcMain.once('hideCheckbox', e => {
    e.returnValue = hideCheckbox;
  });

});

let downloadingUpdate = false;
let updateDownloaded = false;

let downloadedUpdateVersion = '';

autoUpdater.on('update-downloaded', ({ version: v }) => {
  downloadedUpdateVersion = v;
  downloadingUpdate = false;
  updateDownloaded = true;
  storage.setItem('showReleaseNotes', true, true);
  openUpdateAvailableWindow(v, 'updateDownloaded');
});
autoUpdater.on('update-available', res => {
  availableUpdate = res;
  const { version: v } = availableUpdate;
  const ignoreUpdates = storage.getItem('ignoreUpdates') || '';
  if(ignoreUpdates && ignoreUpdates === v) return;
  openUpdateAvailableWindow(v, 'updateAvailable');
});
autoUpdater.on('error', err => {
  updateError = true;
  const patternsToIgnore = [