title: creating tasks using a loop [gulp]
body: <p>I'm trying to dynamically create tasks (minify and concat) based on <strong>jsFiles</strong> object. The <strong>key will give the destination file name and the array contains the src files</strong>. When I run gulp I see all the tasks names being ran but it only writes the last key which is group2.js in this case. What's wrong here?</p>
  
  <pre><code>// imports here
  
  var jsFiles = 
  {
      group1:[file1.js,file2.js],
      group2:[file2.js,file3.js]
  };
  
  for (var key in jsFiles)
  {
      gulp.task(key, function() {
          return gulp.src(jsFiles[key])
          .pipe(jshint())
          .pipe(uglify())
          .pipe(concat(key + '.js'))  // &lt;- HERE
          .pipe(gulp.dest('public/js'));
      });
  }
  
  var defaultTasks = [];
  for (var key in jsFiles)
  {
      defaultTasks.push(key);
  }
  gulp.task('default', defaultTasks);
  </code></pre>