Skip to content

Commit

Permalink
Match against options.pattern when recursing src dir
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonm committed Jun 21, 2014
1 parent 792f191 commit 560875b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -50,7 +50,10 @@ NOTE: The src parameter MUST be a directory. Patterns like "src/*.js" will fail
```js
grunt.initConfig({
blanket: {
options: {},
options: {
// pattern: "**/*interesting*.js"
pattern: "!src/some/dir/to/exclude/**/*"
},
files: {
'src-cov/': ['src/'],
},
Expand Down
6 changes: 5 additions & 1 deletion tasks/blanket.js
Expand Up @@ -45,7 +45,11 @@ module.exports = function(grunt) {
});
grunt.util.async.forEachSeries(src,function(filepath,next) {
grunt.file.recurse(filepath, function(abspath, rootdir, subdir, filename){
if (options.extensions.indexOf(path.extname(filename)) > -1){
var matchesPattern = (options.pattern === undefined) ||
(grunt.file.minimatch(abspath, options.pattern)),
matchesExtensions = options.extensions.indexOf(path.extname(filename)) > -1;

if (matchesPattern && matchesExtensions) {
// Read file source.
var inFile = grunt.file.read(abspath);

Expand Down

1 comment on commit 560875b

@chforster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change is not avaliable on npmjs.com (Version 0.0.8 does not include it)

Please sign in to comment.