title: Create plugin gulp with stream
body: <p>I created plugin for send json data in json file.</p>
  
  <p>But I don't understand why send my object json in pipe, and not write file directly in my plugin.</p>
  
  <p>I want use my plugin whit this syntax:</p>
  
  <pre><code>gulp.task('js-hash', function()
  {
      // Get all js in redis
      gulp.src('./build/js/**/*.js')
          .pipe(getHashFile('/build/js/'))
         .pipe(gulp.dest('./build/js/hash.json'));
  });
  </code></pre>
  
  <p>And not that:</p>
  
  <pre><code>gulp.task('js-hash', function()
  {
      // Get all js in redis
      gulp.src('./build/js/**/*.js')
          .pipe(getHashFile('./build/js/hash.json', '/build/js/'));
  });
  </code></pre>
  
  <p>This is my plugin:</p>
  
  <pre><code>var through = require('through2');
  var gutil = require('gulp-util');
  var crypto = require('crypto');
  var fs = require('fs');
  var PluginError = gutil.PluginError;
  
  // Consts
  const PLUGIN_NAME = 'get-hash-file';
  var json = {};
  
  function getHashFile(filename, basename)
  {
      if (!filename) {
          throw PluginError(PLUGIN_NAME, "Missing filename !");
      }
  
      // Creating a stream through which each file will pass
      var stream = through.obj(function (file, enc, callback) {
          if (file.isNull()) {
              this.push(file); // Do nothing if no contents
            return callback();
          }
  
          if (file.isBuffer()) {
              var hash = crypto.createHash('sha256').update(String(file.contents)).digest('hex');
              json[file.path.replace(file.cwd+basename, '')] = hash;
  
              return callback();
          }
  
          if (file.isStream()) {
              this.emit('error', new PluginError(PLUGIN_NAME, 'Stream not supported!'));
              return callback();
          }
      }).on('finish', function () {
          fs.writeFile(filename, JSON.stringify(json), function(err) {
              if (err) {
                  throw err;
              }
          });
      });
  
  
      // returning the file stream
      return stream;
  }
  
  
  // Exporting the plugin main function
  module.exports = getHashFile;
  </code></pre>
  
  <p>Your are idea</p>