diff --git a/lib/grunt/file.js b/lib/grunt/file.js index c9a7eaeb6..9e545c426 100644 --- a/lib/grunt/file.js +++ b/lib/grunt/file.js @@ -51,6 +51,10 @@ var processPatterns = function(patterns, fn) { var result = []; // Iterate over flattened patterns array. grunt.util._.flatten(patterns).forEach(function(pattern) { + // If the pattern is a function, ignore it + if (typeof pattern === 'function') { + return; + } // If the first character is ! it should be omitted var exclusion = pattern.indexOf('!') === 0; // If the pattern is an exclusion, remove the ! diff --git a/test/grunt/file_test.js b/test/grunt/file_test.js index 613ddc330..a0bdbbcde 100644 --- a/test/grunt/file_test.js +++ b/test/grunt/file_test.js @@ -232,6 +232,11 @@ exports['file.expand*'] = { test.deepEqual(grunt.file.expand(opts, ['js/foo.js', 'js/bar.js', 'js/baz.js']), ['js/foo.js', 'js/bar.js', 'js/baz.js'], 'non-matching filenames should be returned in result set.'); test.done(); }, + 'ignore functions within patterns': function(test) { + test.expect(1); + test.deepEqual(grunt.file.expand(['**/*.js', function() {}]), ['js/bar.js', 'js/foo.js'], 'functions passed in with patterns should be ignored.'); + test.done(); + }, }; exports['file.expandMapping'] = {