使用grunt concat-json排除文件



我使用concat-json合并多个json在一个。然而,目标src不同,这意味着我从两个不同的路径读取。在其中一个路径上,我想排除一个特定的文件,使其不包含在concat上。在npm文档上,我没有找到任何与合并时排除文件相关的内容。

这是我如何指定不同的目标:

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"
    }
  } 
});

可以在Grunt的globing模式中指定排除。

通过以下配置,not-me.json文件将被排除:

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"
        }
    } 
});

最新更新