Answer the question
In order to leave comments, you need to log in
How to create xml using grunt/gulp?
The xml file contains the ide config (paths for ftp deployment).
It lies in the .idea folder, which has no place in the repository.
For each project, it's too lazy to set up paths every time.
Since grunt is used, the idea arose to generate this file with its help.
Just copying is not suitable, since several values need to be changed (the server name in the main).
Is there a plugin for grunt (or gulp) that allows you to create an xml file according to a certain template, substituting the values of variables from the config?
Answer the question
In order to leave comments, you need to log in
For grunt you can write your own , it has a templating engine .
Something like this (not tested):
grunt.registerTask('createXml', 'Creates XML by template', function () {
var template = grunt.file.read(this.data.tpl);
var xml = grunt.template.process(template, this.data.vars);
grunt.file.write(this.target, xml);
});
// пример конфига
grunt.initConfig({
deployPath: 'ftp://example.ftp/',
createXml: {
'.idea/conf.xml': {
tpl: 'path/to/template.xml',
vars: {
var1: '<%= deployPath %>'
}
}
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question