Grunt globbing ignore all directories

Say I have a directory structure and I have a grunt task that does something with source files:

src: [
  "foo/bar/**/*"
]

This will match all files and folders inside foo/bar.

For instance, if I have a grunt task that runs "this.files.forEach", all files and folders will be iterated over. I know I can just check if the item is a file by "grunt.file.isFile", but is there a way to specify in the globbing pattern to only match files?

Answers


I think what you are looking for is the filter option which you can pass 'isFile' to.

Based on the gruntjs docs example, your configuration should look like:

grunt.initConfig({
  clean: {
    foo: {
      src: ["foo/bar/**/*"],
      filter: "isFile",
    },
  },
});

Not quite in the globbing pattern, but still more "declarative" than having to do a this.files.forEach with grunt.file.isFile.


Need Your Help

django template url function not matching in app

python django google-app-engine

I have a django project set up with an app called pub. I'm trying to set it up so that I can include urls.py from each app (there will be more as I go) in the top-level urls.py. I've also got a

How do you do a string replace with javascript using HTML in a script tag

javascript jquery str-replace

I am working on a plugin for WordPress and I need to add multiple settings to be able to add multiple videos. Everything is working except for when I copy the content in the script tag, I am not ab...