Open dusdong opened 8 years ago
that's a great idea!
Unfortunately I don't have free time at the moment, but I'll try to copy-paste something from Stremio. I understand this doesn't help hugely but it's still something:
function quietAutoupdate() {
var updater = new autoupdaty({
fs: require("original-fs"),
manifestUrl: "http://www.strem.io/stremioVersions.json?latest="+Math.floor(Date.now()/(2*60*1000)),
downloadUrl: "http://www.strem.io/Stremio",
runtimeVerProp: "stremioRuntimeVersion",
version: _.pick(require("./package"), "version", "stremioRuntimeVersion"),
filter: function(x) { return !(x.beta || x.alpha || x.experimental) && !x.disabled },
getUpdateUrl: function (downloadUrl, version, platform) {
// ASAR update for Windows
if (platform == 'asar' && process.platform == 'win32') return { url: downloadUrl + version.version + '.asar.exe' };
// Get full exe for Windows
if (platform == 'win32') return { url: downloadUrl + '%20' + version.version + '.exe' }
return { url: downloadUrl + version.version + ({
asar: '.asar.gz',
darwin: '.mac.gz',
linux: '.linux.tar.gz'
})[platform], ungzip: true, untar: platform !== 'asar' }
}
});
updater.check(function(err, newest, manifest) {
if (err) return end(err);
if (!newest) return end("no new version");
msg("preparing version "+newest.version);
updater.prepare(newest, function(err, prepared) {
if (err) return end(err);
ipc.on("terminate", function() { end("prepared version "+newest.version) });
console.log(prepared) // prepared new version - either a directory (OS X full update, linux full update or an exe - Windows updates)
});
});
setTimeout(function() { end("timed out") }, 30*1000);
function msg(message) { console.log("autoupdater: "+(message.error || message)) }
function end(message) { msg(message); app.quit() }
};
The server is just an NGINX hosting those files:
Stremio
Could you write an example app?Contain client and server, Thanks very much!