 request = require 'request'
 progress = require 'request-progress'
 path = require 'path'
+os = require 'os'
 fs = require 'fs'
 
 packageFile = require './package.json'

      console.log "Remote Version: #{remoteVersion}"
      if semver.lt(localVersion, remoteVersion)
        console.log "Remote is newer!"
        self._download_update_mac(appPath,
         "#{updateServer}/#{packageFile.name}-osx-ia32.zip",
         ->
        , cb)
      else
        console.log "No updates."

  _download_update: (appPath, remoteUrl, progressCb, doneCb) ->
    tempName = '.nw-update.zip'
    location = appPath + "/" + tempName

    progress(request(remoteUrl))
      .on('progress', progressCb)
      .on('error', doneCb)
      .pipe(fs.createWriteStream(location))
      .on('close', doneCb)



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

    console.log "Requesting updates"
