module.exports = function (grunt) {

  'use strict';

  var async = require('async');
  var handlebars = require('handlebars');
  var path = require('path');

  var templatesDir = path.resolve(__dirname, '../templates');

  var gitUser = require('../lib/gitUser');
  var gitCommits = require('../lib/gitCommits');
  var getLogs = require('../lib/getLogs');

  var formats = {
    'gmail': require('../lib/gmail'),
    // 'slack': require('../lib/slack'),
    'hipchat': require('../lib/hipchat')
  };

  grunt.registerTask('bilder/reporter', function () {

    var done = this.async();
    var options = this.options({
      'maxCommits': 3,
      'maxDeployments': 2
    });

    var logFile = path.resolve(options.logFile);
    var log = getLogs(logFile);
    var deployment = {
      'user': gitUser(),
      'environment': options.environment,
      'commits': gitCommits(options.maxCommits),
      'release': options.release,
      'date': (new Date(options.timestamp)).toString()
    };

    // keep only a few last deploy logs
    var deployments = log.deployments;
    deployments.unshift(deployment);
    log.deployments = deployments.slice(0, options.maxDeployments);

    // data for templates
    var current = deployments[0];
    var previous = deployments[1];
    var diff = previous && {
      'previous': previous.commits[0].sha1,
      'current': current.commits[0].sha1
    };

    var data = {
      'user': current.user.name,
      'environment': current.environment,
      'repoUrl': options.repoUrl,
      'changed': !!(diff && (diff.previous !== diff.current)),
      'diff': diff,
      'commits': current.commits.map(function (commit) {
        commit.repoUrl = options.repoUrl;
        return commit;
      })
    };

    // send out notifications
    var notifications = Object.keys(formats);
    async.forEach(notifications, function (type, callback) {
      var template = grunt.file.read(path.join(templatesDir, type + '.tmpl'));
      var templateFn = handlebars.compile(template);
      formats[type](data, templateFn, options[type], grunt, callback);
    }, function () {
      grunt.file.write(logFile, JSON.stringify(log, null, 2));
      done();
    });
  });
};
@@ -410,19 +410,16 @@
 l'),%0A   
- //
  'slack'
@@ -657,16 +657,36 @@
 ents': 2
+,%0A      'notify': %5B%5D
 %0A    %7D);
@@ -1812,27 +1812,81 @@
 s = 
-Object.keys(formats
+options.notify.filter(function (key) %7B%0A      return key in formats;%0A    %7D
 );%0A 

enable slack, use options for whitelisting