How to make Gulp.src fail if a file is missing?

Since there didn't seem to be a ready solution for this, I wrote a module to fit our needs.

The files-exist module allows you to check whether all files in an array are present, throwing an error if any are missing. It returns an identical array on success, so it is simple to drop in place.

  var jsFiles = [
    sourcePath + '/config/config.js',
    sourcePath + '/vendor/jquery/dist/jquery.js',
    sourcePath + '/vendor/js-cookie/src/js.cookie.js',
    sourcePath + '/vendor/modernizr/modernizr.js',
    sourcePath + '/vendor/lodash/lodash.js',
    sourcePath + '/vendor/picturefill/dist/picturefill.min.js',
    sourcePath + '/templates/**/*.js',
    sourcePath + '/pages/**/*.js'
  ],

filesExist = require('files-exist'),

gulp.task('build:js', ['jscs'], function() {
  return gulp.src(filesExist(jsFiles)) // Throws error if a file is missing
  .pipe(concat('scripts.js'))
  .pipe(gulpif(isProd, uglify()))
  .pipe(gulp.dest(outputPath + '/webresources/js'));
});