Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hadron-auto-update-manager

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hadron-auto-update-manager - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

144

index.js

@@ -23,3 +23,3 @@ 'use strict';

function AutoUpdateManager(endpointURL) {
function AutoUpdateManager(endpointURL, iconURL) {
if (!endpointURL) {

@@ -29,2 +29,3 @@ throw new TypeError('endpointURL is required!');

this.endpointURL = endpointURL;
this.iconURL = iconURL;
this.version = app.getVersion();

@@ -35,2 +36,3 @@ this.onUpdateError = _.bind(this.onUpdateError, this);

this.feedURL = `${endpointURL}/updates?version=${this.version}`;
debug('auto updater ready and waiting.', {

@@ -41,3 +43,5 @@ version: this.version,

process.nextTick( () => this.setupAutoUpdater());
process.nextTick(() => {
this.setupAutoUpdater();
});
}

@@ -76,25 +80,92 @@ _.extend(AutoUpdateManager.prototype, EventEmitter.prototype);

});
};
this.check({
/**
* @api private
* @return {Boolean} Check scheduled?
*/
AutoUpdateManager.prototype.scheduleUpdateCheck = function() {
if (this.checkForUpdatesIntervalID) {
debug('Update check already scheduled');
return false;
}
var fourHours = 1000 * 60 * 60 * 4;
var checkForUpdates = this.checkForUpdates.bind(this, {
hidePopups: true
});
setInterval((function(_this) {
return function() {
var ref;
if ((ref = _this.state) === UpdateAvailableState || ref === UnsupportedState) {
console.log('Skipping update check... update ready to install, or updater unavailable.');
return;
}
return _this.check({
hidePopups: true
});
};
})(this), 1000 * 60 * 30);
if (autoUpdater.supportsUpdates != null) {
if (!autoUpdater.supportsUpdates()) {
return this.setState(UnsupportedState);
}
this.checkForUpdatesIntervalID = setInterval(checkForUpdates, fourHours);
checkForUpdates();
return true;
},
/**
* @api private
* @return {Boolean} Scheduled check cancelled?
*/
AutoUpdateManager.prototype.cancelScheduledUpdateCheck = function() {
if (this.checkForUpdatesIntervalID) {
clearInterval(this.checkForUpdatesIntervalID);
this.checkForUpdatesIntervalID = null;
debug('cancelled scheduled update check');
return true;
}
return false;
};
AutoUpdateManager.prototype.checkForUpdates = function(opts) {
opts = opts || {};
if (!opts.hidePopups) {
autoUpdater.once('update-not-available', this.onUpdateNotAvailable);
autoUpdater.once('error', this.onUpdateError);
}
debug('checking for updates...');
autoUpdater.checkForUpdates();
return true;
};
/**
* @api public
* @return {Boolean} Auto updates enabled?
*/
AutoUpdateManager.prototype.enable = function() {
if (this.state === 'unsupported') {
debug('Not scheduling because updates are not supported.');
return false;
}
return this.scheduleUpdateCheck();
};
/**
* @api public
*/
AutoUpdateManager.prototype.disable = function() {
this.cancelScheduledUpdateCheck();
};
/**
* @api public
* @return {Boolean} Quit and install update?
*/
AutoUpdateManager.prototype.install = function() {
if (this.state !== 'update-available') {
debug('No update to install');
return false;
}
debug('installing via autoUpdater.quitAndInstall()');
autoUpdater.quitAndInstall();
return true;
};
/**
* Check for updates now bypassing scheduled check.
* @api public
* @return {Boolean} Update check requested?
*/
AutoUpdateManager.prototype.check = function() {
if (this.state === 'unsupported') {
debug('Updates are not supported.');
return false;
}
return this.checkForUpdates();
};
AutoUpdateManager.prototype.emitUpdateAvailableEvent = function() {

@@ -127,33 +198,2 @@ if (!this.releaseVersion) {

AutoUpdateManager.prototype.check = function(arg) {
var hidePopups;
hidePopups = (arg != null ? arg : {}).hidePopups;
if (!hidePopups) {
autoUpdater.once('update-not-available', this.onUpdateNotAvailable);
autoUpdater.once('error', this.onUpdateError);
}
if (process.platform === 'win32') {
return autoUpdater.downloadAndInstallUpdate();
} else {
return autoUpdater.checkForUpdates();
}
};
AutoUpdateManager.prototype.install = function() {
if (process.platform === 'win32') {
return autoUpdater.restartN1();
} else {
return autoUpdater.quitAndInstall();
}
};
AutoUpdateManager.prototype.iconURL = function() {
var url;
url = path.join(process.resourcesPath, 'app', 'nylas.png');
if (!fs.existsSync(url)) {
return void 0;
}
return url;
};
AutoUpdateManager.prototype.onUpdateNotAvailable = function() {

@@ -164,3 +204,3 @@ autoUpdater.removeListener('error', this.onUpdateError);

buttons: ['OK'],
icon: this.iconURL(),
icon: this.iconURL,
message: 'No update available.',

@@ -177,3 +217,3 @@ title: 'No Update Available',

buttons: ['OK'],
icon: this.iconURL(),
icon: this.iconURL,
message: 'There was an error checking for updates.',

@@ -180,0 +220,0 @@ title: 'Update Error',

{
"name": "hadron-auto-update-manager",
"description": "Atoms AutoUpdateManager class as a standalone module.",
"version": "0.0.4",
"version": "0.0.5",
"scripts": {

@@ -6,0 +6,0 @@ "fmt": "mongodb-js-fmt",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc