Our gulp build takes a bunch of libraries installed with bower, then concatenates them with all the code we have distributed across several directories. Here's what it looks like:
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'
],
gulp.task('build:js', ['jscs'], function() {
return gulp.src(jsFiles)
.pipe(concat('scripts.js'))
.pipe(gulpif(isProd, uglify()))
.pipe(gulp.dest(outputPath + '/webresources/js'));
});
Our problem is that whenever someone adds new libraries, other developers will encounter problems if they haven't run bower install
to get the new components. The scripts.js
gets built without them since it won't mind that one of the globs returns empty, even if it is a named file.
How should this be solved? Is there a way to throw an error if a glob returns zero results?