Goodmornig,
I'm using grunt-replace (https://github.com/outaTiME/grunt-replace) inside my gruntfile to replace some string in a html file by loading a json object from a json file.
I want to add some flexibility to this approach and i customized another task called 'setopts' that simply add some properties to the grunt.option that i use i the 'replace' task in the following way:
replace: {
common: {
options: {
patterns: [
{
json: '<%=grunt.option("locales")%>'
}
]
},
files: [
{expand: true, flatten: true, src: ['public/sites/<%=grunt.option("domain")%>/index.html'], dest: 'public/sites/<%=grunt.option("domain")%>/'},
]
}
}
Here my 'setopts' task :
grunt.registerTask('setopts', function (domain) {
locales = grunt.file.readJSON('src/locales/domain/myfile.json');
grunt.option('locales', locales);
grunt.option('domain', domain);
}
I run the following task :
grunt.registerTask('maintask', [ 'setopts:mydomain', 'replace:common']);
After some attempts i found that the 'files' property in the 'replace' task works fine but i get an error in the 'patterns' property :
Processing source...ERROR Warning: Error while processing "public/sites/xxxxx/index.html" file. Use --force to continue.
What's going wrong with this?
Thanks for any comment!