简体   繁体   English

在 Grunt 中复制特定目录名称格式下的所有文件?

[英]Copy all files under specific directory name format in Grunt?

I have translation files under a t9n directory throughout my app...in some component directories, etc.我在整个应用程序的 t9n 目录下都有翻译文件……在某些组件目录等中。

app
components
    ComponentA
        t9n
            translations_A.json
    ComponentB
        t9n
            translations_B.json
t9n
    common-translations.json
    

And I'm looking to create a grunt task to copy all those.json files into an assets directory when the app is built.而且我正在寻找创建一个繁重的任务来在构建应用程序时将所有这些.json 文件复制到assets目录中。

Is there a way to grab all contents under specific directory names?有没有办法获取特定目录名称下的所有内容? So that I could say....for every directory under app, grab the contents of any t9n directory?所以我可以说....对于 app 下的每个目录,获取任何t9n目录的内容?

I know you can do things like...我知道你可以做一些事情,比如......

"**/*.{png}" to say copy all PNG files....but not sure what it would be for the above. "**/*.{png}"表示复制所有 PNG 文件....但不确定上面的内容是什么。

Answer is like mentioned in the comments, "app/**/t9n/*.json particularly I was confused on what globbing patterns were with Grunt https://gruntjs.com/configuring-tasks#globbing-patterns答案就像评论中提到的那样, "app/**/t9n/*.json特别是我对 Grunt https://gruntjs.com/configuring-tasks#globbing-patterns的通配模式感到困惑

I ended up using the files array format from the grunt documentation https://gruntjs.com/configuring-tasks#files-array-format我最终使用了 grunt 文档https://gruntjs.com/configuring-tasks#files-array-format中的文件数组格式

and ended up with something like this...最后得到了这样的东西......

  "build-t9n": {
    files: [
      {
        cwd: "src/app/js",
        src: ["**/t9n/*.json"],
        dest: "build/assets/t9n",
        expand: true
      }
    ]
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM