'use strict';

var bitballoon = require("bitballoon"),
    grunt      = require('grunt'),
    _          = grunt.util._;

var DeployTask = function (origTask) {
  this._origTask = origTask;
};

DeployTask.prototype = {
  run: function() {
    var config = this.getConfig();

    if (!config.src) {
      return config.logErrors && grunt.log.error("No src folder for grunt-bitballoon - skipping deploy");
    }
    if (!config.token) {
      return config.logErrors && grunt.log.error("No token for grunt-bitballoon - skipping deploy");
    }
    if (!config.site) {
      return config.logErrors && grunt.log.error("No site for grunt-bitballoon - skipping deploy");
    }

    client = bitballoon.createClient({access_token: config.token});

    client.site(config.site.replace(/^https?:\/\//, '').replace(/\/$/, ""), function(err, site) {
        if (err) {
          return config.logErrors && grunt.log.error("Site not found - skipping deploy");
        }

        grun.logSuccess && grunt.log.ok("Deploying to BitBalloon");
        site.update({dir: config.src}, function(err) {
          if (err) {
            return config.logErrors && grunt.log.error("Error during deploy", err);
          }

          config.logSuccess && grunt.log.ok("Site deployed to " + site.url);
        });
      });
  },

  getConfig: function() {
    // Grab the options for this task.
    var opts = this._origTask.options();

    var defaultOpts = {
      token: process.env.BB_TOKEN,
      site: process.env.BB_SITE,
      logSuccess: true,
      logErrors: true
    };

    // Combine the options and fileActions as the config
    return _.extend({}, defaultOpts, opts);
  }
}

module.exports = DeployTask;

@@ -835,26 +835,24 @@
 te) %7B%0A      
-  
 if (err) %7B%0A 
@@ -842,34 +842,32 @@
      if (err) %7B%0A
-  
         return c
@@ -940,31 +940,27 @@
 oy%22);%0A      
-  
 %7D%0A%0A
-  
       grun.l
@@ -1015,26 +1015,24 @@
 on%22);%0A      
- 
- 
 site.update(
@@ -1037,16 +1037,29 @@
 e(%7Bdir: 
+path.resolve(
 config.s
@@ -1060,16 +1060,17 @@
 nfig.src
+)
 %7D, funct
@@ -1084,26 +1084,24 @@
 ) %7B%0A        
-  
 if (err) %7B%0A 
@@ -1105,26 +1105,24 @@
 %7B%0A          
- 
- 
 return confi
@@ -1185,31 +1185,27 @@
 r);%0A        
-  
 %7D%0A%0A
-  
         conf
@@ -1273,24 +1273,20 @@
 ;%0A      
-  
 %7D);%0A
-  
     %7D);%0A

Make sure to resolve task