Automatically (and silently) updates node-webkit apps on the background
This code will contact the update API endpoint and if a new version is available, will download and install it.
var gui = require('nw.gui');
var currentVersion = gui.App.manifest.version
var updater = require('nw-updater')({
'channel':'beta',
'currentVersion': currentVersion,
'endpoint': 'http://torrentv.github.io/update.json',
'pubkey': '-----BEGIN RSA PUBLIC KEY-----\nMII...'
})
updater.update() //or updater.check()
updater.on("download", function(version){
console.log("OH YEAH! going to download version "+version)
})
updater.on("installed", function(){
console.log("SUCCCESSFULLY installed, please restart")
})
For an example update.json please visit: http://torrentv.github.io/update.json
With npm:
It is designed to work with builds generated with grunt-node-webkit-builder-for-nw-updater
update.json checksums and signatures can be created using node-sign-release
Kudos for the original authors of this module, the PopcornTime.io developers.