]> khamidou — GitHub mirrors - electron.git/commitdiff
Don't use ES6 class for AutoUpdater windows class
authorKevin Sawicki <kevinsawicki@gmail.com>
Wed, 3 Feb 2016 17:52:04 +0000 (09:52 -0800)
committerKevin Sawicki <kevinsawicki@gmail.com>
Tue, 9 Feb 2016 22:54:17 +0000 (14:54 -0800)
atom/browser/api/lib/auto-updater/auto-updater-win.js

index f8a07902f212edfd8c29d5fb06043832d3f29059..1c81763f35ea1a7076548e00f70bca25c67c82cd 100644 (file)
@@ -4,59 +4,59 @@ const app = require('electron').app;
 const EventEmitter = require('events').EventEmitter;
 const squirrelUpdate = require('./squirrel-update-win');
 
-class AutoUpdater extends EventEmitter {
-  constructor() {
-    super();
-  }
+function AutoUpdater() {
+  EventEmitter.call(this)
+}
 
-  quitAndInstall() {
-    squirrelUpdate.processStart();
-    return app.quit();
-  }
+require('util').inherits(AutoUpdater, EventEmitter);
 
-  setFeedURL(updateURL) {
-    return this.updateURL = updateURL;
-  }
+AutoUpdater.prototype.quitAndInstall = function() {
+  squirrelUpdate.processStart();
+  return app.quit();
+}
+
+AutoUpdater.prototype.setFeedURL = function(updateURL) {
+  return this.updateURL = updateURL;
+}
 
-  checkForUpdates() {
-    if (!this.updateURL) {
-      return this.emitError('Update URL is not set');
-    }
-    if (!squirrelUpdate.supported()) {
-      return this.emitError('Can not find Squirrel');
-    }
-    this.emit('checking-for-update');
-    return squirrelUpdate.download(this.updateURL, (function(_this) {
-      return function(error, update) {
+AutoUpdater.prototype.checkForUpdates = function() {
+  if (!this.updateURL) {
+    return this.emitError('Update URL is not set');
+  }
+  if (!squirrelUpdate.supported()) {
+    return this.emitError('Can not find Squirrel');
+  }
+  this.emit('checking-for-update');
+  return squirrelUpdate.download(this.updateURL, (function(_this) {
+    return function(error, update) {
+      if (error != null) {
+        return _this.emitError(error);
+      }
+      if (update == null) {
+        return _this.emit('update-not-available');
+      }
+      _this.emit('update-available');
+      return squirrelUpdate.update(_this.updateURL, function(error) {
+        var date, releaseNotes, version;
         if (error != null) {
           return _this.emitError(error);
         }
-        if (update == null) {
-          return _this.emit('update-not-available');
-        }
-        _this.emit('update-available');
-        return squirrelUpdate.update(_this.updateURL, function(error) {
-          var date, releaseNotes, version;
-          if (error != null) {
-            return _this.emitError(error);
-          }
-          releaseNotes = update.releaseNotes, version = update.version;
-
-          // Following information is not available on Windows, so fake them.
-          date = new Date;
-          return _this.emit('update-downloaded', {}, releaseNotes, version, date, _this.updateURL, function() {
-            return _this.quitAndInstall();
-          });
+        releaseNotes = update.releaseNotes, version = update.version;
+
+        // Following information is not available on Windows, so fake them.
+        date = new Date;
+        return _this.emit('update-downloaded', {}, releaseNotes, version, date, _this.updateURL, function() {
+          return _this.quitAndInstall();
         });
-      };
-    })(this));
-  }
+      });
+    };
+  })(this));
+}
 
-  // Private: Emit both error object and message, this is to keep compatibility
-  // with Old APIs.
-  emitError(message) {
-    return this.emit('error', new Error(message), message);
-  }
+// Private: Emit both error object and message, this is to keep compatibility
+// with Old APIs.
+AutoUpdater.prototype.emitError = (message) {
+  return this.emit('error', new Error(message), message);
 }
 
 module.exports = new AutoUpdater;