// Generated by CoffeeScript 1.7.1
(function() {
  var EventEmitter, autoUpdater,
    __slice = [].slice;

  autoUpdater = process.atomBinding('auto_updater').autoUpdater;

  EventEmitter = require('events').EventEmitter;

  autoUpdater.__proto__ = EventEmitter.prototype;

  autoUpdater.on('update-downloaded-raw', function() {
    var args;
    args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
    args[3] = new Date(args[3]);
    return this.emit.apply(this, ['update-downloaded'].concat(__slice.call(args), [(function(_this) {
      return function() {
        return _this.quitAndInstall();
      };
    })(this)]));
  });

  autoUpdater.quitAndInstall = function() {
    var BrowserWindow, app, win, windows, _i, _len, _results;
    BrowserWindow = require('browser-window');
    windows = BrowserWindow.getAllWindows();
    if (windows.length === 0) {
      this._quitAndInstall();
      return;
    }
    app = require('app');
    app.removeAllListeners('window-all-closed');
    app.once('window-all-closed', this._quitAndInstall.bind(this));
    _results = [];
    for (_i = 0, _len = windows.length; _i < _len; _i++) {
      win = windows[_i];
      _results.push(win.close());
    }
    return _results;
  };

  module.exports = autoUpdater;

}).call(this);
