 Heroku  = require 'heroku-client'
 tar     = require 'tar'
 fstream = require 'fstream'
+zlib    = require 'zlib'
 request = require 'request'
 
 module.exports = (root, config) ->


create_tar = (root, name) ->
  d = W.defer()
  tar_path = path.join(root, "#{name}.tar")

  stream = fstream.Reader(path: root, type: 'Directory')
    .pipe(tar.Pack(noProprietary: true))
    .pipe(fs.createWriteStream(tar_path))

  stream.on('close', d.resolve.bind(d, tar_path))


check_app_status = (heroku, id, name, d) ->
  heroku.apps(name).builds(id).info().then (res) ->
    switch res.status
      when 'pending'
        check_app_status(heroku, id, name, d)
      else
