简体   繁体   中英

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.

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.

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?

I know you can do things like...

"**/*.{png}" to say copy all PNG files....but not sure what it would be for the above.

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

I ended up using the files array format from the grunt documentation 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
      }
    ]
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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