API Updater - mugifly/electron-updater-gh-releases GitHub Wiki
Methods for Updater
new Updater(options)
Parameter - options
- appVersion: [Required] An current verson string -- e.g. "1.0.0"
- execFileName: [Required] An executable file name of the app -- e.g. example.exe -> "example"
- releaseFileNamePrefix: [Required] A prefix for release filename (zip-archive) on GitHub -- e.g. example-win32-ia32-v1.0.0.zip -> "example-"
- ghAccountName: [Required] Your GitHub account name -- e.g. "mugifly"
- ghRepoName: [Required] Your GitHub repository name -- e.g. "electron-updater-gh-releases-example"
- tmpDirPrefix: A prefix for temporary directory
- userAgent: An User-Agent string for accessing to api
- updateCheckedAt: A last of update checking date (epoch millisecond)
- funcSaveUpdateCheckdAt: An function for save a update checking date
- updateCheckInterval: An minimum interval for update checking (millisecond)
- isDebug: Enable debug logging
- isDryRun: If true, it will not to update a files of the app
Example
var Updater = require('electron-updater-gh-releases');
Updater.doSelfTestIfNeeded();
// Make an instance of Updater
var updater = new Updater({
// Required options
appVersion: manifest.version,
execFileName: 'example',
releaseFileNamePrefix: 'example-',
ghAccountName: 'mugifly',
ghRepoName: 'electron-updater-gh-releases-example',
// If you want to consider an interval for update checking,
// You should be set following options.
funcSaveUpdateCheckdAt: function(update_checked_at) {
// Please store the value of update_checked_at
// to LocalStorage or any storage.
},
updateCheckedAt: 0, // A stored value of update_checked_at
updateCheckInterval: 60 * 60 * 12 * 1000 // Interval in millisec
});
doSelfTestIfNeeded()
Execute the self testing mode if needed. This method can called as a static method; You MUST CALL it when the app started.
In addition, it will consider whether should be execute himself.
Example
var app = require('app');
// Do self test if needed
var Updater = require('electron-updater-gh-releases');
Updater.doSelfTestIfNeeded();
app.on('ready', function() {
// ....
});
checkAndUpdate(callback)
Check a newer version and update the app.
NOTE: This method is handy. However, if you want to confirm about updating to user, you should use to checkUpdateAvailable and update method.
Parameters
callback
function(is_successful, is_available, version_string, error_string)
checkUpdateAvailable(callback)
Check whether there is newer version
Parameters
callback
function(is_available, version_string, asset, error_string)
update(version_str, asset, callback)
Update to specific version.
Parameters
version
An obtained variable from an callback of checkUpdateAvailable method.
asset
An obtained variable from an callback of checkUpdateAvailable method.
callback
function(is_successful, error_string)
getSuitableAsset(assets)
Under construction...