I can't figure out for the life of me how to get this work. The grunt configuration for a module I'm using (grunt-sloc) requires the Files Object Format. Using this, I want to be able to match all regular files (i.e., non-directories) immediately under the top level directory.
For example, say this is my directory structure, where +
signifies a directory and -
signifies a regular file:
repo
+ dir
- unwanted.js
- server.js
How do I use Grunt's Files Object Format to match server.js
but not dir
or dir/unwanted.js
?
This is how it would look in the Compact Fomat:
mine: {
src: [
'*'
]
}
Or, in bash, you would get them like this:
ls -p | grep -v /;
Here's what I've tried with the Files Object Format:
This does not work:
mine: { files: { '.': ['*'] } }
Neither does this:
mine: { files: { './': ['*'] } }
Not even this:
mine: { files: { './': ['*/server.js'] } }
Nor this:
mine: { files: { './': ['server.js'] } }
This works, but it runs recursively, which I do not want:
mine: { files: { './': ['**/server.js'] } }
After doing a bunch of testing and code reading, I've verified that it is in fact the minimatch package (a depencency of Grunt), which is not returning the matches I'm looking for. So it is not the grunt module I am using; it's my grunt configuration.
Since Grunt is so popular and this seems like a very common use case, I'm guessing that there's a way to do this. Does anyone know what that is?
Update
As RobC
pointed out, my last example does NOT work. It was picking up server.js
's in my node_modules
directory, which made me think it was working.