I am looking for a better way to combine json files supporting a specific structure using Grunt.
Files are located in folders in the following structure:
The app
├── locales
│ ├── en
│ │ └── translation.json
│ ├── es
│ │ └── translation.json
│ └── fr
│ └── translation.json
└── widgets
├── Posts
│ └── locales
│ ├── en
│ │ └── translation.json
│ ├── es
│ │ └── translation.json
│ └── fr
│ └── translation.json
├── Comments
│ └── locales
│ ├── en
│ │ └── translation.json
│ ├── es
│ │ └── translation.json
│ └── fr
│ └── translation.json
└── Links
├── locales
│ ├── en
│ │ └── translation.json
│ ├── es
│ │ └── translation.json
│ └── fr
│ └── translation.json
And the desired result with the merged files would be:
The app
│
├── lang
│ ├── en
│ │ └── translation.json
│ ├── es
│ │ └── translation.json
│ └── fr
│ └── translation.json
├── locales
└── widgets
So far I have come up with one solution using grunt-contrib-concat, but I think there should be a better way to do this.
concat: { translateEN: { src: [ 'www/js/app/locales/en/*.json', 'www/js/app/widgets/posts/locales/en/*.json', 'www/js/app/widgets/comments/locales/en/*.json', 'www/js/app/widgets/links/locales/en/*.json' ], dest: 'www/js/app/lang/en/translation.json', options: { banner: '{', footer: "}", separator: ',' } }, translateES: { src: [ 'www/js/app/locales/es/*.json', 'www/js/app/widgets/posts/locales/es/*.json', 'www/js/app/widgets/comments/locales/es/*.json', 'www/js/app/widgets/links/locales/es/*.json' ], dest: 'www/js/app/lang/es/translation.json', options: { banner: '{', footer: "}", separator: ',' } }, translateFR: { src: [ 'www/js/app/locales/fr/*.json', 'www/js/app/widgets/posts/locales/fr/*.json', 'www/js/app/widgets/comments/locales/fr/*.json', 'www/js/app/widgets/links/locales/fr/*.json' ], dest: 'www/js/app/lang/fr/translation.json', options: { banner: '{', footer: "}", separator: ',' } } }