ck86 / main-bower-files

Getting all main bower files
583 stars 56 forks source link

Error if bower dependencies are empty #159

Open Horttcore opened 7 years ago

Horttcore commented 7 years ago

It might be pointless, but it would be good if there won't be an error if there are no dependencies in the bower.json.

Here is an example from my gulpfile.

 *
 * Task: Scripts
 *
 * - Sourcemap
 * - Combine
 * - Concat
 * - Minify
 * - Sync browsers
 *
 */
gulp.task('scripts', function() {
    var filterJS = plugins.filter(['**/*.js','!jquery.fancybox.pack.js']); // Broken by fancy
    return gulp.src(mainBowerFiles({
            paths: {
                bowerDirectory: 'src/bower_components',
                bowerrc: '.bowerrc',
                bowerJson: 'bower.json'
            },
        }))
        .pipe(filterJS)
        .pipe(plugins.addSrc.append('src/scripts/plugins/*.js'))
        .pipe(plugins.addSrc.append('src/scripts/*.js'))
        .pipe(plugins.plumber({errorHandler: plugins.notify.onError("Error: <%= error.message %>")}))
        .pipe(plugins.sourcemaps.init())
        .pipe(plugins.concat('scripts.combined.js'))
        .pipe(gulp.dest('dist/scripts'))
        .pipe(plugins.rename({suffix: '.min'}))
        .pipe(plugins.uglify())
        .pipe(plugins.sourcemaps.write('./'))
        .pipe(gulp.dest('dist/scripts'))
        .pipe(plugins.notify("Scripts updated"))
        .pipe(browserSync.stream());
});
ck86 commented 7 years ago

Why would you use it if you don't have dependencies?

Horttcore commented 7 years ago

By default I have a lightbox and slider script. But sometimes I need none of them, so returning an empty array wouldn't block the rest of my default build script.

This is more like error preventing.

ck86 commented 7 years ago

I don't get the point. You use the same gulp task for every project? When do you have the dependencies and when not?