gruntjs path filter : exclude files start with _

Problem

I use grunt-contrib-jade, and wanted to specify the task for all jade files, except ones starts with an underscore.

current:

jade: {
            dist: {
                options: {
                    pretty: true
                },
                files: [
                    {
                        expand: true,
                        cwd: '/',
                        dest: '.tmp',
                        src: '{,basedir/**/}*.jade',
                        ext: '.html'
                    }
                ]
            }
        },

this compiles all *.jade files within basedir. I want to exclude all jade files within the hierarchy, where the file names start with _

It looks like it may not be specific to jade, but how grunt tasks specified with the filter syntax. So, how to specify below filter, to indicate to exclude files start with _ to be excluded.

'{,basedir/**/}*.jade'

Thanks

Problem courtesy of: bsr

Solution

You can specify an array of strings for src, and can exclude files with ! at the beginning of the string (see the file object format documentation here):

src: ['{,basedir/**/}*.jade', '!{,basedir/**/}_*.jade']

Hopefully you can get it from there, I'm not terrible familiar with the globbing syntax.

Solution courtesy of: Corey

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.