Jose Bernhardt Jose Bernhardt - 2 months ago 14
Node.js Question

Exclude file with grunt concat-json

I'm using

concat-json
to merge multiples
json
in a single one. However, the target
src
varies, meaning that I read from two different paths.
On one of those paths, I want to exclude a specific file to not be included on the
concat
. On the
npm
docs I dont find anything related to exclude a file while merging.

This is how I specify different targets:

grunt.initConfig({
"concat-json": {
"en": {
src: [ "reports/*.json" ],
dest: "reports/request.json"
},
"de": {
//Here is where I want to merge all jsons but one in specific
src: [ "reports/temp/*.json" ],
dest: "reports/request.json"
}
}
});

Answer

You can specify exclusions in Grunt globbing patterns.

With the following configuration, the not-me.json file will be excluded:

grunt.initConfig({
    "concat-json": {
        "en": {
            src: ["reports/*.json"],
            dest: "reports/request.json"
        },
        "de": {
            src: ["reports/temp/*.json", "!reports/temp/not-me.json"],
            dest: "reports/request.json"
        }
    } 
});