How can I use a glob to ignore files that start with an underscore?

Alan2 picture Alan2 · Dec 29, 2014 · Viewed 12.8k times · Source

I am using this file matching in gulp:

'content/css/*.css'

But I would like to only include the files that do not start with an underscore. Can someone tell me how I can do this?

Here's the code:

gulp.task('less', function () {
    gulp.src('content/less/*.less')
        .pipe(less())
        .pipe(gulp.dest('content/css'));
});

Answer

Barmar picture Barmar · Dec 29, 2014

If Gulp wildcards are like shell wildcards:

content/css/[^_]*.css

The ^ at the beginning of a character set means to match any characters not in the set.