Skip to content

Commit

Permalink
more fixes for autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmark committed Apr 27, 2018
1 parent 93cf175 commit d61a569
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .electron-vue/webpack.main.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
process.env.BABEL_ENV = 'main'

const path = require('path')
const { dependencies } = require('../package.json')
const { dependencies, version } = require('../package.json')
const webpack = require('webpack')
const crypto = require('crypto')
const fs = require('fs')
Expand Down Expand Up @@ -72,9 +72,14 @@ if (process.env.NODE_ENV === 'production') {
)
}

let channel = 'latest'
if ( version.indexOf('beta') >= 0 ) channel = 'beta'
else if (version.indexOf('alpha') >= 0 ) channel = 'alpha'

mainConfig.plugins.push(
new webpack.DefinePlugin({
'AI2HTML_HASH': `"${crypto.createHash('sha1').update(fs.readFileSync(path.join(__dirname, '../static/ai2html.js'))).digest('hex')}"`
'AI2HTML_HASH': `"${crypto.createHash('sha1').update(fs.readFileSync(path.join(__dirname, '../static/ai2html.js'))).digest('hex')}"`,
'AUTOUPDATE_CHANNEL': `"${channel}"`
})
)

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"build": {
"productName": "Vizier",
"appId": "com.voxmedia.vizier",
"generateUpdatesFilesForAllChannels": true,
"directories": {
"output": "build"
},
Expand Down
8 changes: 7 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,11 @@ app.on('activate', () => {
import { autoUpdater } from 'electron-updater'

app.on('ready', () => {
if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdatesAndNotify()
if (process.env.NODE_ENV === 'production') {
// This is supposedly unnecessary. But it doesn't work without it.
autoUpdater.channel = AUTOUPDATE_CHANNEL
autoUpdater.setFeedURL('https://apps.voxmedia.com/vizapp/')

autoUpdater.checkForUpdatesAndNotify()
}
})

0 comments on commit d61a569

Please sign in to comment.