1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 02:06:29 +00:00

Check update if the app is packaged

This commit is contained in:
Junyoung Choi
2019-02-08 18:56:11 +09:00
parent e53717cd87
commit 2ff655d2dc

View File

@@ -3,8 +3,9 @@ const app = electron.app
const Menu = electron.Menu const Menu = electron.Menu
const ipc = electron.ipcMain const ipc = electron.ipcMain
const GhReleases = require('electron-gh-releases') const GhReleases = require('electron-gh-releases')
const isDev = process.env.NODE_ENV !== 'production' const { isPackaged } = app
// electron.crashReporter.start() // electron.crashReporter.start()
var ipcServer = null var ipcServer = null
var mainWindow = null var mainWindow = null
@@ -36,7 +37,7 @@ const updater = new GhReleases(ghReleasesOpts)
// Check for updates // Check for updates
// `status` returns true if there is a new update available // `status` returns true if there is a new update available
function checkUpdate () { function checkUpdate () {
if (isDev) { // Prevents app from attempting to update when in dev mode. if (!isPackaged) { // Prevents app from attempting to update when in dev mode.
console.log('Updates are disabled in Development mode, see main-app.js') console.log('Updates are disabled in Development mode, see main-app.js')
return true return true
} }
@@ -99,12 +100,12 @@ app.on('ready', function () {
// Check update every day // Check update every day
setInterval(function () { setInterval(function () {
if (!isDev) checkUpdate() if (isPackaged) checkUpdate()
}, 1000 * 60 * 60 * 24) }, 1000 * 60 * 60 * 24)
// Check update after 10 secs to prevent file locking of Windows // Check update after 10 secs to prevent file locking of Windows
setTimeout(() => { setTimeout(() => {
if (!isDev) checkUpdate() if (isPackaged) checkUpdate()
ipc.on('update-check', function (event, msg) { ipc.on('update-check', function (event, msg) {
if (isUpdateReady) { if (isUpdateReady) {