title: Pipe vendor js files from Bower and own js files into unique stream in Gulp
body: <p>I'd like to grab my vendor js files from bower dependencies, and, along with my own js files, pipe through some other tasks and concat them into one .js file. And then do the same for Sass files.</p>
  
  <p>How could I achieve that? I tried this, but it doesn't work:</p>
  
  <pre><code>gulp.task('scripts', function () {
     return gulp.src([
          mainBowerFiles(gulpFilter('*.js')),
          'app/js/*.js'
          ])
        .pipe(uglify())
        .pipe(concat('app.js'))
        .pipe(gulp.dest('./dist/js'));
  });
  </code></pre>
  
  <p>It throws this error:</p>
  
  <pre><code>TypeError: Arguments to path.resolve must be strings
  </code></pre>
  
  <p>But it works if I have this, for example:</p>
  
  <pre><code>gulp.src([
      'app/js/etc.js',
      'app/js/main.js'
  ])
  </code></pre>
  
  <p>..and in the following case, it throws a different error (but no error without uglify()):</p>
  
  <pre><code>gulp.src(mainBowerFiles(gulpFilter('*.js')))
  </code></pre>
  
  <p>error: </p>
  
  <pre><code>events.js:72
          throw er; // Unhandled 'error' event
  </code></pre>
  
  <p>How do I better debug this? Should I separate vendor / own js files in different streams?</p>
  
  <p><strong>update</strong></p>
  
  <p>I'm working now with two streams, and merging them later on with <code>event-stream</code>, like this:</p>
  
  <pre><code>gulp.task('scripts', function () {
  
      var jsFilter = gulpFilter('*.js');
      var vendorFiles = gulp.src(mainBowerFiles()) // don't read
          .pipe(jsFilter)
          .pipe(concat('vendor.js'));
  
      var appFiles = gulp.src('app/js/*.js')
          .pipe(jshint())
          .pipe(jshint.reporter('default'))
          .pipe(concat('app.js'));
  
      return es.concat(vendorFiles, appFiles)
          .pipe(uglify())
          .pipe(concat('app.js'))
          .pipe(gulp.dest('./dist/js'));
  });
  </code></pre>
  
  <p>It works great, but I'm not able to handle the order of the files. Obviously I'd like that the vendor code come before my code at the destination's <code>app.js</code>, but that's doesn't happen. I created a thread about that <a href="https://stackoverflow.com/questions/25768789/order-when-concat-streams-with-event-stream-in-gulp">here</a>.</p>