]> khamidou — GitHub mirrors - electron.git/commitdiff
Move implementation of auto-updater on OS X to another file
authorCheng Zhao <zcbenz@gmail.com>
Fri, 23 Oct 2015 07:13:24 +0000 (15:13 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 23 Oct 2015 07:13:24 +0000 (15:13 +0800)
atom/browser/api/lib/auto-updater.coffee
atom/browser/api/lib/auto-updater/auto-updater-mac.coffee [new file with mode: 0644]
filenames.gypi

index 7e3fa99a76d92506d15cd20b94bcd76c4adeedcd..41b78a00d7e09509bf7b5e2d51bf7a6df386ca14 100644 (file)
@@ -1,25 +1,7 @@
-if process.platform is 'win32'
-  module.exports = require './auto-updater/auto-updater-win'
-  return
-
-# Implementation on OS X.
-autoUpdater  = process.atomBinding('auto_updater').autoUpdater
-EventEmitter = require('events').EventEmitter
-
-autoUpdater.__proto__ = EventEmitter.prototype
-
-autoUpdater.quitAndInstall = ->
-  # If we don't have any window then quitAndInstall immediately.
-  BrowserWindow = require 'browser-window'
-  windows = BrowserWindow.getAllWindows()
-  if windows.length is 0
-    @_quitAndInstall()
-    return
-
-  # Do the restart after all windows have been closed.
-  app = require 'app'
-  app.removeAllListeners 'window-all-closed'
-  app.once 'window-all-closed', @_quitAndInstall.bind(this)
-  win.close() for win in windows
-
-module.exports = autoUpdater
+switch process.platform
+  when 'win32'
+    module.exports = require './auto-updater/auto-updater-win'
+  when 'darwin'
+    module.exports = require './auto-updater/auto-updater-mac'
+  else
+    throw new Error('auto-updater is not implemented on this platform')
diff --git a/atom/browser/api/lib/auto-updater/auto-updater-mac.coffee b/atom/browser/api/lib/auto-updater/auto-updater-mac.coffee
new file mode 100644 (file)
index 0000000..9ec9f3f
--- /dev/null
@@ -0,0 +1,20 @@
+{EventEmitter} = require 'events'
+{autoUpdater} = process.atomBinding 'auto_updater'
+
+autoUpdater.__proto__ = EventEmitter.prototype
+
+autoUpdater.quitAndInstall = ->
+  # If we don't have any window then quitAndInstall immediately.
+  BrowserWindow = require 'browser-window'
+  windows = BrowserWindow.getAllWindows()
+  if windows.length is 0
+    @_quitAndInstall()
+    return
+
+  # Do the restart after all windows have been closed.
+  app = require 'app'
+  app.removeAllListeners 'window-all-closed'
+  app.once 'window-all-closed', @_quitAndInstall.bind(this)
+  win.close() for win in windows
+
+module.exports = autoUpdater
index 389c245ffa8ab6fe27a93ecdc9521db37fa5badc..f6a7dbd086805177d2e0abdfcf579b813394bdb3 100644 (file)
@@ -11,6 +11,7 @@
       'atom/browser/api/lib/app.coffee',
       'atom/browser/api/lib/atom-delegate.coffee',
       'atom/browser/api/lib/auto-updater.coffee',
+      'atom/browser/api/lib/auto-updater/auto-updater-mac.coffee',
       'atom/browser/api/lib/auto-updater/auto-updater-win.coffee',
       'atom/browser/api/lib/auto-updater/squirrel-update-win.coffee',
       'atom/browser/api/lib/browser-window.coffee',