-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e97848b
commit c0bdb70
Showing
6 changed files
with
174 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const autoUpdater = require('electron-updater'); | ||
const { dialog, BrowserWindow, ipcMain } = require('electron'); | ||
const log = require('electron-log'); | ||
|
||
let downloadProgress; | ||
log.transports.file.level = "debug"; | ||
autoUpdater.autoUpdater.logger = log; | ||
|
||
autoUpdater.autoUpdater.autoDownload = false; | ||
|
||
autoUpdater.autoUpdater.setFeedURL({ | ||
provider: "github", | ||
owner: "hannydevelop", | ||
repo: "peppubuild-desktop", | ||
}); | ||
|
||
function check() { | ||
autoUpdater.autoUpdater.checkForUpdates(); | ||
|
||
autoUpdater.autoUpdater.on('checking-for-update', () => { | ||
const response = dialog.showMessageBox(null); | ||
console.log(response); | ||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Update Available', | ||
message: 'A new version of app is available. Do you want to update now?', | ||
buttons: ['Update', 'No'] | ||
}, (index) => { | ||
if (index) { | ||
return; | ||
} else { | ||
autoUpdater.autoUpdater.downloadUpdate(); | ||
|
||
let proWin = new BrowserWindow({ | ||
width: 350, | ||
height: 35, | ||
useContentSize: true, | ||
autoHideMenuBar: true, | ||
maximizable: false, | ||
fullscreen: false, | ||
fullscreenable: false, | ||
resizable: false, | ||
title: 'Downloading Update' | ||
}); | ||
proWin.loadURL(`file://$(__dirname)/progress`); | ||
|
||
proWin.on('closed', () => { | ||
proWin = null; | ||
}); | ||
|
||
ipcMain.on('download-progress-request', (e) => { | ||
e.returnValue = downloadProgress; | ||
}); | ||
|
||
autoUpdater.autoUpdater.on('download-progress', (d) => { | ||
downloadProgress = d.percent; | ||
autoUpdater.autoUpdater.logger.info(downloadProgress); | ||
}); | ||
|
||
autoUpdater.autoUpdater.on('update-downloaded', () => { | ||
if (progressWindow) progressWindow.close(); | ||
|
||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Update Ready', | ||
message: 'A new version of app is ready. Quit and Install now?', | ||
buttons: ['Yes', 'Later'] | ||
}, (index) => { | ||
if (!index) { | ||
autoUpdater.autoUpdater.quitAndInstall(); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
module.exports.check = check; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters