       .pipe(fs.createWriteStream(targetPath))
       .on('close', doneCb)
 
+  _extract_update: (sourceZip, targetFolder, done) ->
+    unzipper = new DecompressZip(sourceZip)
+    unzipper.on 'error', done
+    unzipper.on 'extract', (log) -> done(null)
+    unzipper.extract({
+      path: targetFolder
+      })
 
   _update_win: (cb) ->
 
   _update_linux: (cb) ->
 
+  is_update_available: (cb) ->
+    request "#{updateServer}/package.json", (error, response, body) ->
+      if error?
+        cb(error)
+        return
+
+      remotePackage = JSON.parse body
+      remoteVersion = remotePackage.version
+      cb(null, semver.lt(localVersion, remoteVersion))
+
 window.Updater = Updater

path = require 'path'
os = require 'os'
fs = require 'fs'

packageFile = require './package.json'


    filePath = execPath.substr(0, execPath.lastIndexOf("\\"))
    appPath = path.normalize(execPath ) #+ "/../../../../../../..")
    downloadTarget = os.tmpdir() + "/" + ".update.zip"
    extractFolder = os.tmpdir() + "/update/"
    self = this

    console.log "Requesting updates"
    this.is_update_available (err, update_available) ->
      if update_available
        self._download_update(downloadTarget,
         "#{updateServer}/#{packageFile.name}-osx-ia32.zip",
         (state) ->
           console.log state
        , () ->
          self._extract_update downloadTarget, extractFolder, (err) ->
            console.log err
            cb(err)
        )
      else
        console.log "No updates."

