grunt
grunt copied to clipboard
Add missing filtering of task `src` files
trafficstars
The documentation mentions that one can filter the source files with a custom filter function. After some failed attempts at using that feature I had a look at the source and noticed the filter feature works only in some cases (compact & files array).
I've added some tests for the filter-thing and made it work for the following file configurations:
// Compact (http://gruntjs.com/configuring-tasks#compact-format)
target1: {
dest: 'dist/file1.js',
src: [ 'one/**/*.js' ],
filter: filterFn
},
// Files object (http://gruntjs.com/configuring-tasks#files-object-format)
target2: {
files: {
'dist/file1.js': [ 'one/**/*.js' ],
'dist/file2.js': [ 'two/**/*.js' ]
},
filter: filterFn
},
// Files array (http://gruntjs.com/configuring-tasks#files-array-format)
target3: {
files: [
{ dest: 'dist/file1.js', src: [ 'one/**/*.js' ], filter: filterFn },
{ dest: 'dist/file2.js', src: [ 'two/**/*.js' ], filter: filterFn }
]
},
// Files objects in array (undocumented?)
target4: {
files: [
{ 'dist/file1.js': [ 'one/**/*.js' ] },
{ 'dist/file2.js': [ 'two/**/*.js' ] }
],
filter: filterFn
},
Note that the resulting files object does not contain the filter property (but .orig does).