Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { app, BrowserWindow } from 'electron';
import modifyProcessEnv from './utils/modifyProcessEnv';
import { createWindow } from './window';
import handleIPC from './ipc';
import { checkForUpdates } from './utils/autoUpdater';

process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';

app.whenReady().then(() => {
checkForUpdates();

modifyProcessEnv();

createWindow();
Expand Down
46 changes: 46 additions & 0 deletions main/utils/autoUpdater.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { NsisUpdater, MacUpdater, AppImageUpdater } from 'electron-updater';
import * as isDev from 'electron-is-dev';
import log from './log';

let AutoUpdater;
if (process.platform === 'win32') {
AutoUpdater = NsisUpdater;
} else if (process.platform === 'darwin') {
AutoUpdater = MacUpdater;
} else {
AutoUpdater = AppImageUpdater;
}

const autoUpdater = new AutoUpdater();

autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';

autoUpdater.on('checking-for-update', () => {
log.info('checking-for-update');
});
autoUpdater.on('update-available', (info) => {
log.info('update-available', info);
});
autoUpdater.on('update-not-available', (info) => {
log.info('update-not-available', info);
});
autoUpdater.on('error', (error) => {
log.error('error', error);
});
autoUpdater.on('download-progress', (meta) => {
log.info('download-progress', meta);
});
autoUpdater.on('update-downloaded', (info) => {
log.info('update-downloaded', info);
});

export function checkForUpdates() {
if (isDev) {
return;
}
autoUpdater.checkForUpdates();
}

export default autoUpdater;

Loading