Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dialog.showMessageBox(mainWindow, {
type: 'info',
title: i18n.__('dialog.updateInstallLater.title'),
message: i18n.__('dialog.updateInstallLater.message'),
buttons: [i18n.__('dialog.updateInstallLater.ok')],
defaultId: 0,
});
return;
}
mainWindow.removeAllListeners();
app.removeAllListeners('window-all-closed');
try {
autoUpdater.quitAndInstall();
} catch (e) {
autoUpdater.emit('error', e);
}
};
autoUpdater.emit('update-available', {
version: 'v0.0.0',
releaseDate: 'July 24th, 1985 asdfasdf asdfafds asdf asdf asfd asadfasd as dff',
releaseNotes: `
1. Feature 1
2. Feature 2
3. Feature 3
4. Feature 4
5. Feature 5
6. Feature 6
7. Feature 7
`,
});
} else {
await B.delay(5000);
autoUpdater.emit('update-not-available');
}
};
setTimeout(() => {
if (i >= 5 && shouldMockUpdateError) {
if (i === 5) {
autoUpdater.emit(
AutoUpdaterEvents.ERROR,
new Error('Test error, nothing actually failed')
);
}
return;
}
const total = 150000000;
autoUpdater.emit(AutoUpdaterEvents.DOWNLOAD_PROGRESS, {
bytesPerSecond: Math.round(Math.random() * 100000000),
percent: i * 10,
transferred: total / i,
total
});
if (i === 10) {
autoUpdater.emit(AutoUpdaterEvents.UPDATE_DOWNLOADED);
}
}, 500 * i);
}
new Error('Test error, nothing actually failed')
);
}
return;
}
const total = 150000000;
autoUpdater.emit(AutoUpdaterEvents.DOWNLOAD_PROGRESS, {
bytesPerSecond: Math.round(Math.random() * 100000000),
percent: i * 10,
transferred: total / i,
total
});
if (i === 10) {
autoUpdater.emit(AutoUpdaterEvents.UPDATE_DOWNLOADED);
}
}, 500 * i);
}
function mockUpdateCheck() {
autoUpdater.emit(AutoUpdaterEvents.CHECKING_FOR_UPDATE);
setTimeout(() => {
autoUpdater.emit(AutoUpdaterEvents.UPDATE_AVAILABLE, TEST_RELEASE);
}, 3000);
}
autoUpdater.downloadUpdate = async () => {
let progress = {
bytesPerSecond: 100000,
percent: 0,
total: 10000000,
transferred: 1000000,
};
while (progress.percent <= 100) {
await B.delay(2000);
autoUpdater.emit('download-progress', progress);
if (fail && progress.percent > 50) {
return autoUpdater.emit('error', new Error('An error occurred'));
}
progress.bytesPerSecond += (Math.random() * 50) - 24.999999999;
progress.percent += 19.999991;
progress.total = 499.999999999 * 1000000;
progress.transferred += 100.0000000001 * 1000000;
}
updateDone = true;
autoUpdater.emit('update-downloaded');
};
setTimeout(() => {
autoUpdater.emit(AutoUpdaterEvents.UPDATE_AVAILABLE, TEST_RELEASE);
}, 3000);
}
setTimeout(() => {
if (i >= 5 && shouldMockUpdateError) {
if (i === 5) {
autoUpdater.emit(
AutoUpdaterEvents.ERROR,
new Error('Test error, nothing actually failed')
);
}
return;
}
const total = 150000000;
autoUpdater.emit(AutoUpdaterEvents.DOWNLOAD_PROGRESS, {
bytesPerSecond: Math.round(Math.random() * 100000000),
percent: i * 10,
transferred: total / i,
total
});
if (i === 10) {
autoUpdater.checkForUpdates = async () => {
if (update && !updateDone) {
await B.delay(Math.random() * 10000);
autoUpdater.emit('update-available', {
version: 'v0.0.0',
releaseDate: 'July 24th, 1985 asdfasdf asdfafds asdf asdf asfd asadfasd as dff',
releaseNotes: `
1. Feature 1
2. Feature 2
3. Feature 3
4. Feature 4
5. Feature 5
6. Feature 6
7. Feature 7
`,
});
} else {
await B.delay(5000);
autoUpdater.emit('update-not-available');
}